devela/num/dom/int/wrapper/
namespace.rs1#[doc = crate::_tags!(num namespace)]
7#[doc = crate::_doc_meta!{location("num/dom/int")}]
9#[doc = crate::doclink!(custom devela "[`NumInt`]" "num/trait.NumInt.html")]
36#[must_use]
37#[repr(transparent)]
38pub struct Int<T>(pub T);
39
40crate::_num_dom_impl_arith![Int: i8, i16, i32, i64, i128, isize];
41crate::_num_dom_impl_arith![Int: (no_neg) u8, u16, u32, u64, u128, usize];
42#[rustfmt::skip]
43mod core_impls {
44 use crate::{impl_trait, Int, Ordering, ValueQuant};
45
46 impl<T: Clone> Clone for Int<T> {
47 fn clone(&self) -> Self { Self(self.0.clone()) }
48 }
49 impl<T: Copy> Copy for Int<T> {}
50
51 impl_trait![fmt::Debug for Int[T][T] where T |self, f|
52 f.debug_tuple("Int").field(&self.0).finish()
53 ];
54 impl_trait![fmt::Display for Int[T][T] where T |self, f| self.0.fmt(f)];
55 impl_trait![fmt::Binary for Int[T][T] where T |self, f| self.0.fmt(f)];
56 impl_trait![fmt::Octal for Int[T][T] where T |self, f| self.0.fmt(f)];
57 impl_trait![fmt::LowerHex for Int[T][T] where T |self, f| self.0.fmt(f)];
58 impl_trait![fmt::UpperHex for Int[T][T] where T |self, f| self.0.fmt(f)];
59 impl_trait![fmt::LowerExp for Int[T][T] where T |self, f| self.0.fmt(f)];
60 impl_trait![fmt::UpperExp for Int[T][T] where T |self, f| self.0.fmt(f)];
61
62 impl<T: PartialEq> PartialEq for Int<T> {
65 fn eq(&self, other: &Self) -> bool { self.0.eq(&other.0) }
66 }
67 impl<T: Eq> Eq for Int<T> {}
68 impl<T: PartialEq> PartialEq<T> for Int<T> {
70 fn eq(&self, other: &T) -> bool { self.0.eq(other) }
71 }
72
73 impl<T: PartialOrd> PartialOrd for Int<T> {
76 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
77 self.0.partial_cmp(&other.0)
78 }
79 }
80 impl<T: Ord> Ord for Int<T> {
81 fn cmp(&self, other: &Self) -> Ordering {
82 self.0.cmp(&other.0)
83 }
84 }
85 impl<T: PartialOrd> PartialOrd<T> for Int<T> {
87 fn partial_cmp(&self, other: &T) -> Option<Ordering> {
88 self.0.partial_cmp(other)
89 }
90 }
91
92 impl_trait![Hash for Int[T][T] where T |self, s| self.0.hash(s)];
93
94 impl<T: PartialEq> PartialEq<ValueQuant<T, T>> for ValueQuant<Int<T>, Int<T>> {
96 fn eq(&self, other: &ValueQuant<T, T>) -> bool {
97 self.v.eq(&other.v) && self.q.eq(&other.q)
98 }
99 }
100 impl<T: PartialEq> PartialEq<ValueQuant<Int<T>, Int<T>>> for ValueQuant<T, T> {
101 fn eq(&self, other: &ValueQuant<Int<T>, Int<T>>) -> bool {
102 self.v.eq(&other.v.0) && self.q.eq(&other.q.0)
103 }
104 }
105 impl<T: PartialEq> PartialEq<(T, T)> for ValueQuant<Int<T>, Int<T>> {
107 fn eq(&self, other: &(T, T)) -> bool {
108 self.v.eq(&other.0) && self.q.eq(&other.1)
109 }
110 }
111 impl<T: PartialEq> PartialEq<(Int<T>, Int<T>)> for ValueQuant<T, T> {
112 fn eq(&self, other: &(Int<T>, Int<T>)) -> bool {
113 self.v.eq(&other.0.0) && self.q.eq(&other.1.0)
114 }
115 }
116}