pub trait TryClone: Sized {
// Required method
fn try_clone(&self) -> Result<Self, AllocError>;
// Provided method
fn try_clone_from(&mut self, source: &Self) -> Result<(), AllocError> { ... }
}Expand description
Tries to clone, return an error instead of panic if allocation failed.
Required Methods§
fn try_clone(&self) -> Result<Self, AllocError>
Provided Methods§
Sourcefn try_clone_from(&mut self, source: &Self) -> Result<(), AllocError>
fn try_clone_from(&mut self, source: &Self) -> Result<(), AllocError>
Performs copy-assignment from source.
a.try_clone_from(&b) is equivalent to a = b.try_clone() in functionality,
but can be overridden to reuse the resources of a to avoid unnecessary
allocations.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.