devela/data/codec/bit/wrapper/
mod.rs
1mod primitives;
7
8#[cfg(all(test, feature = "_bit_u8"))]
9mod tests;
10
11#[doc = crate::TAG_NAMESPACE!()]
12#[repr(transparent)]
33#[cfg_attr(feature = "nightly_doc", doc(cfg(_bit··)))]
34pub struct Bitwise<T>(pub T);
35
36#[rustfmt::skip]
37mod core_impls {
38 use {super::Bitwise, core::{fmt, cmp, hash}};
39
40 impl<T: Clone> Clone for Bitwise<T> {
41 #[must_use]
42 fn clone(&self) -> Self { Self(self.0.clone()) }
43 }
44 impl<T: Copy> Copy for Bitwise<T> {}
45 impl<T: fmt::Debug> fmt::Debug for Bitwise<T> {
46 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
47 f.debug_tuple("Bitwise").field(&self.0).finish()
48 }
49 }
50 impl<T: fmt::Display> fmt::Display for Bitwise<T> {
51 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
52 }
53 impl<T: fmt::Binary> fmt::Binary for Bitwise<T> {
54 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Binary::fmt(&self.0, f) }
55 }
56 impl<T: fmt::Octal> fmt::Octal for Bitwise<T> {
57 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Octal::fmt(&self.0, f) }
58 }
59 impl<T: fmt::LowerHex> fmt::LowerHex for Bitwise<T> {
60 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
61 }
62 impl<T: fmt::UpperHex> fmt::UpperHex for Bitwise<T> {
63 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }
64 }
65 impl<T: fmt::UpperExp> fmt::UpperExp for Bitwise<T> {
66 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperExp::fmt(&self.0, f) }
67 }
68 impl<T: fmt::LowerExp> fmt::LowerExp for Bitwise<T> {
69 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerExp::fmt(&self.0, f) }
70 }
71
72 impl<T: PartialEq> PartialEq for Bitwise<T> {
73 #[must_use]
74 fn eq(&self, other: &Self) -> bool { self.0.eq(&other.0) }
75 }
76 impl<T: Eq> Eq for Bitwise<T> {}
77 impl<T: PartialOrd> PartialOrd for Bitwise<T> {
78 #[must_use]
79 fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
80 self.0.partial_cmp(&other.0)
81 }
82 }
83 impl<T: Ord> Ord for Bitwise<T> {
84 #[must_use]
85 fn cmp(&self, other: &Self) -> cmp::Ordering {
86 self.0.cmp(&other.0)
87 }
88 }
89 impl<T: hash::Hash> hash::Hash for Bitwise<T> {
90 fn hash<H: hash::Hasher>(&self, state: &mut H) {
91 self.0.hash(state);
92 }
93 }
94 impl<T: hash::Hasher> hash::Hasher for Bitwise<T> {
95 #[must_use]
96 fn finish(&self) -> u64 {
97 self.0.finish()
98 }
99 fn write(&mut self, bytes: &[u8]) {
100 self.0.write(bytes);
101 }
102 }
103}