jrsonnet_gcmodule/
cc_impls.rs1use crate::Cc;
4use crate::Trace;
5use crate::cc::RawCc;
6use crate::collect::ObjectSpace as O;
7use std::cmp::Ordering;
8use std::fmt;
9use std::hash;
10use std::ops::Deref;
11
12impl<T: Default + Trace> Default for Cc<T> {
13 #[inline]
14 fn default() -> Cc<T> {
15 Self::new(Default::default())
16 }
17}
18
19impl<T: PartialEq + ?Sized> PartialEq for RawCc<T, O> {
20 #[inline]
21 fn eq(&self, other: &RawCc<T, O>) -> bool {
22 **self == **other
23 }
24}
25
26impl<T: hash::Hash + ?Sized> hash::Hash for RawCc<T, O> {
27 fn hash<H: hash::Hasher>(&self, state: &mut H) {
28 (**self).hash(state)
29 }
30}
31
32impl<T: Eq + ?Sized> Eq for RawCc<T, O> {}
33
34impl<T: PartialOrd + ?Sized> PartialOrd for RawCc<T, O> {
35 #[inline]
36 fn partial_cmp(&self, other: &RawCc<T, O>) -> Option<Ordering> {
37 (**self).partial_cmp(&**other)
38 }
39
40 #[inline]
41 fn lt(&self, other: &RawCc<T, O>) -> bool {
42 **self < **other
43 }
44
45 #[inline]
46 fn le(&self, other: &RawCc<T, O>) -> bool {
47 **self <= **other
48 }
49
50 #[inline]
51 fn gt(&self, other: &RawCc<T, O>) -> bool {
52 **self > **other
53 }
54
55 #[inline]
56 fn ge(&self, other: &RawCc<T, O>) -> bool {
57 **self >= **other
58 }
59}
60
61impl<T: Ord + ?Sized> Ord for RawCc<T, O> {
62 #[inline]
63 fn cmp(&self, other: &RawCc<T, O>) -> Ordering {
64 (**self).cmp(&**other)
65 }
66}
67
68impl<T: fmt::Debug + ?Sized> fmt::Debug for RawCc<T, O> {
69 #[inline]
70 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
71 f.debug_tuple("Cc").field(&self.inner().deref()).finish()
72 }
73}
74
75impl<T: fmt::Display + ?Sized> fmt::Display for RawCc<T, O> {
76 #[inline]
77 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78 (**self).fmt(f)
79 }
80}
81
82impl<T: ?Sized> fmt::Pointer for RawCc<T, O> {
83 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
84 fmt::Pointer::fmt(&self.inner().deref(), f)
85 }
86}