[−][src]Macro objekt::clone_trait_object
Implement the standard library Clone
for a trait object that has
objekt::Clone
as a supertrait.
ⓘThis code runs with edition 2018
trait MyTrait: objekt::Clone { /* ... */ } objekt::clone_trait_object!(MyTrait); // Now data structures containing Box<MyTrait> can derive Clone. #[derive(Clone)] struct Container { trait_object: Box<MyTrait>, }
The macro supports traits that have type parameters and/or where
clauses.
ⓘThis code runs with edition 2018
use std::io::Read; trait Difficult<R>: objekt::Clone where R: Read { /* ... */ } objekt::clone_trait_object!(<R> Difficult<R> where R: Read);