pub trait ImplicitClone: Clone {
    // Provided method
    fn implicit_clone(&self) -> Self { ... }
}
Expand description

Marker trait for cheap-to-clone types that should be allowed to be cloned implicitly.

Enables host libraries to have the same syntax as Copy while calling the Clone implementation instead.

Provided Methods§

source

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.

Implementations on Foreign Types§

source§

impl ImplicitClone for bool

source§

impl ImplicitClone for char

source§

impl ImplicitClone for f32

source§

impl ImplicitClone for f64

source§

impl ImplicitClone for i8

source§

impl ImplicitClone for i16

source§

impl ImplicitClone for i32

source§

impl ImplicitClone for i64

source§

impl ImplicitClone for i128

source§

impl ImplicitClone for isize

source§

impl ImplicitClone for u8

source§

impl ImplicitClone for u16

source§

impl ImplicitClone for u32

source§

impl ImplicitClone for u64

source§

impl ImplicitClone for u128

source§

impl ImplicitClone for ()

source§

impl ImplicitClone for usize

source§

impl<T1: ImplicitClone> ImplicitClone for (T1,)

source§

impl<T1: ImplicitClone, T2: ImplicitClone> ImplicitClone for (T1, T2)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone> ImplicitClone for (T1, T2, T3)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone> ImplicitClone for (T1, T2, T3, T4)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone, T8: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7, T8)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone, T8: ImplicitClone, T9: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7, T8, T9)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone, T8: ImplicitClone, T9: ImplicitClone, T10: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone, T8: ImplicitClone, T9: ImplicitClone, T10: ImplicitClone, T11: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)

source§

impl<T1: ImplicitClone, T2: ImplicitClone, T3: ImplicitClone, T4: ImplicitClone, T5: ImplicitClone, T6: ImplicitClone, T7: ImplicitClone, T8: ImplicitClone, T9: ImplicitClone, T10: ImplicitClone, T11: ImplicitClone, T12: ImplicitClone> ImplicitClone for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)

source§

impl<T: ImplicitClone> ImplicitClone for Option<T>

source§

impl<T: ?Sized> ImplicitClone for &T

source§

impl<T: ?Sized> ImplicitClone for Rc<T>

source§

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

source§

impl<const N: usize, T: ImplicitClone> ImplicitClone for [T; N]

Implementors§

source§

impl ImplicitClone for implicit_clone::sync::IString

source§

impl ImplicitClone for implicit_clone::unsync::IString

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> ImplicitClone for implicit_clone::sync::IMap<K, V>

source§

impl<K: Eq + Hash + ImplicitClone + 'static, V: PartialEq + ImplicitClone + 'static> ImplicitClone for implicit_clone::unsync::IMap<K, V>

source§

impl<T: ImplicitClone + 'static> ImplicitClone for implicit_clone::sync::IArray<T>

source§

impl<T: ImplicitClone + 'static> ImplicitClone for implicit_clone::unsync::IArray<T>