scsys_core/id/impls/
impl_id.rs

1/*
2    appellation: impl_id <module>
3    authors: @FL03
4*/
5use crate::id::Id;
6
7impl<T> AsRef<T> for Id<T> {
8    fn as_ref(&self) -> &T {
9        self.get()
10    }
11}
12
13impl<T> AsMut<T> for Id<T> {
14    fn as_mut(&mut self) -> &mut T {
15        self.get_mut()
16    }
17}
18
19impl<T> core::borrow::Borrow<T> for Id<T> {
20    fn borrow(&self) -> &T {
21        self.get()
22    }
23}
24
25impl<T> core::borrow::BorrowMut<T> for Id<T> {
26    fn borrow_mut(&mut self) -> &mut T {
27        self.get_mut()
28    }
29}
30
31impl<T> core::ops::Deref for Id<T> {
32    type Target = T;
33
34    fn deref(&self) -> &Self::Target {
35        self.get()
36    }
37}
38
39impl<T> core::ops::DerefMut for Id<T> {
40    fn deref_mut(&mut self) -> &mut Self::Target {
41        self.get_mut()
42    }
43}
44
45impl<Q> PartialEq<Q> for Id<Q>
46where
47    Q: PartialEq,
48{
49    fn eq(&self, other: &Q) -> bool {
50        self.get() == other
51    }
52}
53
54impl<'a, Q> PartialEq<&'a Q> for Id<Q>
55where
56    Q: PartialEq,
57{
58    fn eq(&self, other: &&'a Q) -> bool {
59        self.get() == *other
60    }
61}
62
63impl<'a, Q> PartialEq<&'a mut Q> for Id<Q>
64where
65    Q: PartialEq,
66{
67    fn eq(&self, other: &&'a mut Q) -> bool {
68        self.get() == *other
69    }
70}
71
72impl<Q> PartialOrd<Q> for Id<Q>
73where
74    Q: PartialOrd,
75{
76    fn partial_cmp(&self, other: &Q) -> Option<core::cmp::Ordering> {
77        self.get().partial_cmp(other)
78    }
79}
80
81contained::fmt_wrapper! {
82    impl Id<T> {
83        Debug,
84        Display,
85        LowerExp,
86        UpperExp,
87        LowerHex,
88        UpperHex,
89        Binary,
90        Octal,
91        Pointer,
92    }
93}