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
29
30
31
32
33
34
35
36
37
use crate::Same;

impl<T: Same> Same for Option<T> {
    fn same(&self, other: &Self) -> bool {
        match (self, other) {
            (Some(a), Some(b)) => a.same(b),
            (None, None) => true,
            _ => false,
        }
    }
}

macro_rules! same_for_eq {
    ($($typ:ty),*) => {
        $(
            impl Same for $typ {
                fn same(&self, other: &Self) -> bool {
                    self == other
                }
            }
        )*
    }
}

same_for_eq! { u8, u16, u32, u64, i8, i16, i32, i64, char, str, String }

#[cfg(feature = "snake_case-impl")]
same_for_eq! { snake_case::SnakeCase }

#[cfg(feature = "uuid-impl")]
same_for_eq! { uuid::Uuid }

impl<T: Same + ?Sized> Same for &T {
    fn same(&self, other: &Self) -> bool {
        (*self).same(*other)
    }
}