1/// A variant of the `Clone` trait which can fail. 2pub trait TryClone: Sized { 3 type Error; 4 5 fn try_clone(&self) -> Result<Self, Self::Error>; 6 fn try_clone_from(&mut self, source: &Self) -> Result<(), Self::Error> { 7 *self = source.try_clone()?; 8 Ok(()) 9 } 10}