use crate::CheapClone;
impl<T> CheapClone for std::rc::Rc<T> {
fn cheap_clone(&self) -> Self {
std::rc::Rc::clone(self)
}
}
macro_rules! impl_copy {
( $($t:ty),* ) => {
$(
impl CheapClone for $t {
fn cheap_clone(&self) -> Self
{
*self
}
}
) *
}
}
impl_copy!(
(),
bool,
u8, u16, u32, u64, u128, usize,
i8, i16, i32, i64, i128, isize,
f32, f64
);
impl<T: CheapClone> CheapClone for Option<T> {
fn cheap_clone(&self) -> Self {
self.as_ref().map(|v| v.cheap_clone())
}
}