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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Additional impls about `AbstractCc<T, O>` to make it easier to use.

use crate::cc::RawCc;
use crate::collect::ObjectSpace as O;
use crate::Cc;
use crate::Trace;
use std::cmp::Ordering;
use std::fmt;
use std::hash;
use std::ops::Deref;

impl<T: Default + Trace> Default for Cc<T> {
    #[inline]
    fn default() -> Cc<T> {
        Self::new(Default::default())
    }
}

impl<T: PartialEq + ?Sized> PartialEq for RawCc<T, O> {
    #[inline]
    fn eq(&self, other: &RawCc<T, O>) -> bool {
        **self == **other
    }
}

impl<T: hash::Hash + ?Sized> hash::Hash for RawCc<T, O> {
    fn hash<H: hash::Hasher>(&self, state: &mut H) {
        (**self).hash(state)
    }
}

impl<T: Eq + ?Sized> Eq for RawCc<T, O> {}

impl<T: PartialOrd + ?Sized> PartialOrd for RawCc<T, O> {
    #[inline]
    fn partial_cmp(&self, other: &RawCc<T, O>) -> Option<Ordering> {
        (**self).partial_cmp(&**other)
    }

    #[inline]
    fn lt(&self, other: &RawCc<T, O>) -> bool {
        **self < **other
    }

    #[inline]
    fn le(&self, other: &RawCc<T, O>) -> bool {
        **self <= **other
    }

    #[inline]
    fn gt(&self, other: &RawCc<T, O>) -> bool {
        **self > **other
    }

    #[inline]
    fn ge(&self, other: &RawCc<T, O>) -> bool {
        **self >= **other
    }
}

impl<T: Ord + ?Sized> Ord for RawCc<T, O> {
    #[inline]
    fn cmp(&self, other: &RawCc<T, O>) -> Ordering {
        (**self).cmp(&**other)
    }
}

impl<T: fmt::Debug + ?Sized> fmt::Debug for RawCc<T, O> {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_tuple("Cc").field(&self.inner().deref()).finish()
    }
}

impl<T: fmt::Display + ?Sized> fmt::Display for RawCc<T, O> {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        (**self).fmt(f)
    }
}

impl<T: ?Sized> fmt::Pointer for RawCc<T, O> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Pointer::fmt(&self.inner().deref(), f)
    }
}