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§

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

Source§

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

Source§

impl TryClone for i8

Source§

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

Source§

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

Source§

impl TryClone for i16

Source§

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

Source§

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

Source§

impl TryClone for i32

Source§

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

Source§

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

Source§

impl TryClone for i64

Source§

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

Source§

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

Source§

impl TryClone for i128

Source§

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

Source§

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

Source§

impl TryClone for isize

Source§

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

Source§

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

Source§

impl TryClone for u8

Source§

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

Source§

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

Source§

impl TryClone for u16

Source§

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

Source§

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

Source§

impl TryClone for u32

Source§

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

Source§

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

Source§

impl TryClone for u64

Source§

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

Source§

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

Source§

impl TryClone for u128

Source§

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

Source§

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

Source§

impl TryClone for usize

Source§

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

Source§

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

Source§

impl TryClone for Global

Source§

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

Source§

impl TryClone for String

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T: ?Sized> TryClone for &T

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§