#[derive(DeepClone)]
{
// Attributes available to this derive:
#[deepclone]
}
Expand description
Derive DeepClone, cloning every field through the same Cloner.
Structs (named, tuple, and unit), enums, generics, and where-clauses are supported; unions
are not. Every type parameter gains a DeepClone bound, as derive(Clone) adds a Clone
bound.
Nothing here inspects field types: Rc and Arc reach the cloner through their own
DeepClone impls, so Vec<Rc<T>> and HashMap<K, Rc<T>> work too, which a derive
matching on the literal token Rc would miss.
No 'static bound is added, so a generic type with an Rc<..T..> field needs T: 'static
on its own declaration.
§Field attributes
#[deepclone(clone)]— useClone::clone. Correct for immutable or unshared data, never for anRcyou want independent.#[deepclone(with = path)]— callpath(&field, cloner).#[deepclone(default)]— ignore the source value and useDefault::default().
§Container attributes
#[deepclone(bound = "T: MyBound")]— replace the generated bounds, for when aDeepClonebound on every parameter is too strong.