SmartClone

Trait SmartClone 

Source
pub trait SmartClone<T: ?Sized + ToOwned> {
    // Required method
    fn smart_clone(&self) -> Cow<'_, T>;
}
Expand description

Efficient clone reduction for hot paths

Required Methods§

Source

fn smart_clone(&self) -> Cow<'_, T>

Clone only if necessary, otherwise return reference

Implementations on Foreign Types§

Source§

impl SmartClone<str> for String

Source§

fn smart_clone(&self) -> Cow<'_, str>

Source§

impl<T: Clone> SmartClone<[T]> for Vec<T>

Source§

fn smart_clone(&self) -> Cow<'_, [T]>

Implementors§