devela/num/int/wrapper/
namespace.rs
#[doc = crate::TAG_NAMESPACE!()]
#[repr(transparent)]
pub struct Int<T>(pub T);
crate::num::impl_ops![Int:
i8:"_int_i8",
i16:"_int_i16",
i32:"_int_i32",
i64:"_int_i64",
i128:"_int_i128",
isize:"_int_isize"];
crate::num::impl_ops![Int: (no_neg)
u8:"_int_i8",
u16:"_int_u16",
u32:"_int_u32",
u64:"_int_u64",
u128:"_int_u128",
usize:"_int_usize"];
#[rustfmt::skip]
mod core_impls {
use core::fmt;
use crate::{Hash, Hasher, Int, Ordering, ValueQuant};
impl<T: Clone> Clone for Int<T> {
#[must_use]
fn clone(&self) -> Self { Self(self.0.clone()) }
}
impl<T: Copy> Copy for Int<T> {}
impl<T: fmt::Debug> fmt::Debug for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("Int").field(&self.0).finish()
}
}
impl<T: fmt::Display> fmt::Display for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
}
impl<T: fmt::Binary> fmt::Binary for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Binary::fmt(&self.0, f) }
}
impl<T: fmt::Octal> fmt::Octal for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Octal::fmt(&self.0, f) }
}
impl<T: fmt::LowerHex> fmt::LowerHex for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
}
impl<T: fmt::UpperHex> fmt::UpperHex for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.0, f) }
}
impl<T: fmt::UpperExp> fmt::UpperExp for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperExp::fmt(&self.0, f) }
}
impl<T: fmt::LowerExp> fmt::LowerExp for Int<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerExp::fmt(&self.0, f) }
}
impl<T: PartialEq> PartialEq for Int<T> {
#[must_use]
fn eq(&self, other: &Self) -> bool { self.0.eq(&other.0) }
}
impl<T: Eq> Eq for Int<T> {}
impl<T: PartialEq> PartialEq<T> for Int<T> {
#[must_use]
fn eq(&self, other: &T) -> bool { self.0.eq(other) }
}
impl<T: PartialEq> PartialEq<ValueQuant<T, T>> for ValueQuant<Int<T>, Int<T>> {
#[must_use]
fn eq(&self, other: &ValueQuant<T, T>) -> bool {
self.v.eq(&other.v) && self.q.eq(&other.q)
}
}
impl<T: PartialEq> PartialEq<ValueQuant<Int<T>, Int<T>>> for ValueQuant<T, T> {
#[must_use]
fn eq(&self, other: &ValueQuant<Int<T>, Int<T>>) -> bool {
self.v.eq(&other.v.0) && self.q.eq(&other.q.0)
}
}
impl<T: PartialEq> PartialEq<(T, T)> for ValueQuant<Int<T>, Int<T>> {
#[must_use]
fn eq(&self, other: &(T, T)) -> bool {
self.v.eq(&other.0) && self.q.eq(&other.1)
}
}
impl<T: PartialEq> PartialEq<(Int<T>, Int<T>)> for ValueQuant<T, T> {
#[must_use]
fn eq(&self, other: &(Int<T>, Int<T>)) -> bool {
self.v.eq(&other.0.0) && self.q.eq(&other.1.0)
}
}
impl<T: PartialOrd> PartialOrd for Int<T> {
#[must_use]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl<T: Ord> Ord for Int<T> {
#[must_use]
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}
}
impl<T: PartialOrd> PartialOrd<T> for Int<T> {
#[must_use]
fn partial_cmp(&self, other: &T) -> Option<Ordering> {
self.0.partial_cmp(other)
}
}
impl<T: Hash> Hash for Int<T> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.hash(state);
}
}
impl<T: Hasher> Hasher for Int<T> {
#[must_use]
fn finish(&self) -> u64 {
self.0.finish()
}
fn write(&mut self, bytes: &[u8]) {
self.0.write(bytes);
}
}
}