pub trait WalkTypeAbleClone<X, Y>{
// Required method
fn clone_box(&self) -> Box<dyn WalkTypeAble<X, Y>>;
}Expand description
Object-safe helper trait that exposes a Clone-compatible operation for
WalkTypeAble trait objects.
Clone::clone requires Self: Sized, so it cannot be invoked through
dyn WalkTypeAble<X, Y> directly. WalkTypeAbleClone::clone_box returns an
owned Box<dyn WalkTypeAble<X, Y>> instead, which lets the generic
Clone for Box<dyn WalkTypeAble<X, Y>> implementation work uniformly for
any concrete walker that is Clone + 'static.
You should never implement this trait by hand: a blanket impl covers every
T: WalkTypeAble<X, Y> + Clone + 'static. Just #[derive(Clone)] on your
concrete walker and the trait object gains Clone for free.
Required Methods§
Sourcefn clone_box(&self) -> Box<dyn WalkTypeAble<X, Y>>
fn clone_box(&self) -> Box<dyn WalkTypeAble<X, Y>>
Returns a boxed clone of this walker as a trait object.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".