Trait implicit_clone::ImplicitClone
source · pub trait ImplicitClone: Clone {
// Provided method
fn implicit_clone(&self) -> Self { ... }
}
Expand description
Provided Methods§
sourcefn implicit_clone(&self) -> Self
fn implicit_clone(&self) -> Self
This function is not magic; it is literally defined as
ⓘ
fn implicit_clone(&self) -> Self {
self.clone()
}
It is useful when you want to clone but also ensure that the type implements
ImplicitClone
.
Examples:
use implicit_clone::ImplicitClone;
let x: u32 = Default::default();
let clone = ImplicitClone::implicit_clone(&x);
ⓘ
use implicit_clone::ImplicitClone;
let x: Vec<u32> = Default::default();
// does not compile because Vec<_> does not implement ImplicitClone
let clone = ImplicitClone::implicit_clone(&x);
Object Safety§
This trait is not object safe.