diff --git a/Cargo.toml b/Cargo.toml index 368d57f..e7eb4f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,4 @@ travis-ci = { repository = "programble/fix" } i128 = ["typenum/i128"] [dependencies] -typenum = "1.9.0" +typenum = "1.11" diff --git a/src/lib.rs b/src/lib.rs index 48cf98c..ef2c883 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,9 +75,7 @@ pub extern crate typenum; /// Type aliases. pub mod aliases; -use core::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}; use core::fmt::{Debug, Error, Formatter}; -use core::hash::{Hash, Hasher}; use core::marker::PhantomData; use core::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; use core::ops::{Add, Div, Mul, Neg, Rem, Sub}; @@ -114,6 +112,7 @@ use typenum::type_operators::{Abs, IsLess}; /// - _(x BE) × y = (x × y) BE_ /// - _(x BE) ÷ y = (x ÷ y) BE_ /// - _(x BE) % y = (x % y) BE_ +#[derive(Copy, Clone, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct Fix { /// The underlying integer. pub bits: Bits, @@ -225,28 +224,6 @@ mod __i128 { // The usual traits. -impl Copy for Fix where Bits: Copy { } -impl Clone for Fix -where Bits: Clone { - fn clone(&self) -> Self { - Self::new(self.bits.clone()) - } -} - -impl Default for Fix -where Bits: Default { - fn default() -> Self { - Self::new(Bits::default()) - } -} - -impl Hash for Fix -where Bits: Hash { - fn hash(&self, state: &mut H) where H: Hasher { - self.bits.hash(state); - } -} - impl Debug for Fix where Bits: Debug, Base: Unsigned, Exp: Integer { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { @@ -254,30 +231,6 @@ where Bits: Debug, Base: Unsigned, Exp: Integer { } } -// Comparison. - -impl Eq for Fix where Bits: Eq { } -impl PartialEq for Fix -where Bits: PartialEq { - fn eq(&self, rhs: &Self) -> bool { - self.bits == rhs.bits - } -} - -impl PartialOrd for Fix -where Bits: PartialOrd { - fn partial_cmp(&self, rhs: &Self) -> Option { - self.bits.partial_cmp(&rhs.bits) - } -} - -impl Ord for Fix -where Bits: Ord { - fn cmp(&self, rhs: &Self) -> Ordering { - self.bits.cmp(&rhs.bits) - } -} - // Arithmetic. impl Neg for Fix