tagptr/
macros.rs

1#[macro_use]
2mod doc;
3
4macro_rules! impl_clone {
5    () => {
6        #[inline]
7        fn clone(&self) -> Self {
8            Self { inner: self.inner, _marker: PhantomData }
9        }
10    };
11}
12
13macro_rules! impl_debug {
14    ($type_name:expr) => {
15        #[inline]
16        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17            let (ptr, tag) = self.decompose();
18            f.debug_struct($type_name).field("ptr", &ptr).field("tag", &tag).finish()
19        }
20    };
21}
22
23macro_rules! impl_default {
24    () => {
25        #[inline]
26        fn default() -> Self {
27            Self::null()
28        }
29    };
30}
31
32macro_rules! impl_pointer {
33    () => {
34        #[inline]
35        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
36            fmt::Pointer::fmt(&self.decompose_ptr(), f)
37        }
38    };
39}
40
41macro_rules! impl_partial_eq {
42    () => {
43        #[inline]
44        fn eq(&self, other: &Self) -> bool {
45            self.inner.eq(&other.inner)
46        }
47    };
48}
49
50macro_rules! impl_partial_ord {
51    () => {
52        #[inline]
53        fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
54            self.inner.partial_cmp(&other.inner)
55        }
56    };
57}
58
59macro_rules! impl_ord {
60    () => {
61        #[inline]
62        fn cmp(&self, other: &Self) -> cmp::Ordering {
63            self.inner.cmp(&other.inner)
64        }
65    };
66}
67
68macro_rules! impl_hash {
69    () => {
70        #[inline]
71        fn hash<H: Hasher>(&self, state: &mut H) {
72            self.inner.hash(state)
73        }
74    };
75}