TryClone

Trait TryClone 

Source
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§

Source

fn try_clone(&self) -> Result<Self, AllocError>

Provided Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl TryClone for bool

Source§

impl TryClone for i8

Source§

impl TryClone for i16

Source§

impl TryClone for i32

Source§

impl TryClone for i64

Source§

impl TryClone for i128

Source§

impl TryClone for isize

Source§

impl TryClone for u8

Source§

impl TryClone for u16

Source§

impl TryClone for u32

Source§

impl TryClone for u64

Source§

impl TryClone for u128

Source§

impl TryClone for usize

Source§

impl TryClone for String

Source§

impl<T> TryClone for Option<T>
where T: TryClone,

Source§

fn try_clone(&self) -> Result<Option<T>, AllocError>

Source§

fn try_clone_from(&mut self, source: &Option<T>) -> Result<(), AllocError>

Source§

impl<T> TryClone for &T
where T: ?Sized,

Source§

impl<T> TryClone for Arc<T>
where T: ?Sized,

Source§

impl<T> TryClone for Weak<T>
where T: ?Sized,

Source§

impl<T, A> TryClone for Box<T, A>
where T: TryClone, A: Allocator + TryClone,

Source§

fn try_clone(&self) -> Result<Box<T, A>, AllocError>

Implementors§

Source§

impl TryClone for Global

Source§

impl<T: TryClone, A: Allocator + TryClone> TryClone for fallacy_box::Box<T, A>