palette/macros/
copy_clone.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
macro_rules! impl_copy_clone {
    (  $self_ty: ident , [$($element: ident),+] $(, $phantom: ident)?) => {
        impl_copy_clone!($self_ty<>, [$($element),+] $(, $phantom)?);
    };
    (  $self_ty: ident < $($phantom_ty: ident)? > , [$($element: ident),+] $(, $phantom: ident)?) => {
        impl<$($phantom_ty,)? T> Copy for $self_ty<$($phantom_ty,)? T> where T: Copy {}

        impl<$($phantom_ty,)? T> Clone for $self_ty<$($phantom_ty,)? T>
        where
            T: Clone,
        {
            fn clone(&self) -> $self_ty<$($phantom_ty,)? T> {
                $self_ty {
                    $($element: self.$element.clone(),)*
                    $($phantom: core::marker::PhantomData,)?
                }
            }
        }
    }
}