1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#![no_std] extern crate void; pub mod iter; pub use core::convert::{TryFrom, TryInto}; use void::Void; pub trait TryClone: Sized { type Error; fn try_clone(&self) -> Result<Self, Self::Error>; fn try_clone_from(&mut self, other: &Self) -> Result<(), Self::Error> { other.try_clone().map(|new| *self = new) } } impl<T: Clone> TryClone for T { type Error = Void; #[inline(always)] fn try_clone(&self) -> Result<Self, Void> { Ok(self.clone()) } #[inline(always)] fn try_clone_from(&mut self, other: &Self) -> Result<(), Void> { Ok(self.clone_from(other)) } }