diff --git a/src/identities.rs b/src/identities.rs index 45c8cc6..25130ff 100644 --- a/src/identities.rs +++ b/src/identities.rs @@ -33,10 +33,10 @@ pub trait Zero: Sized + Add { /// expressed as compile-time constants. /// /// This is implemented for all primitive types, and should be implemented -/// wherever possible. Implementors must ensure that `ZeroConst::ZERO` is +/// wherever possible. Implementors must ensure that `ConstZero::ZERO` is /// the same value produced by [`Zero::zero()`](trait.Zero.html#tymethod.zero). #[cfg(has_associated_consts)] -pub trait ZeroConst: Zero { +pub trait ConstZero: Zero { /// Additive identity: see [`Zero::zero()`](trait.Zero.html#tymethod.zero). const ZERO: Self; } @@ -60,7 +60,7 @@ macro_rules! zero_impl { macro_rules! zero_const_impl { ($t:ty, $v:expr) => { zero_impl!($t, $v); - impl ZeroConst for $t { + impl ConstZero for $t { const ZERO: $t = $v; } }; @@ -107,7 +107,7 @@ where } #[cfg(has_associated_consts)] -impl ZeroConst for Wrapping +impl ConstZero for Wrapping where Wrapping: Zero, { @@ -156,10 +156,10 @@ pub trait One: Sized + Mul { /// expressed as compile-time constants. /// /// This is implemented for all primitive types, and should be implemented -/// wherever possible. Implementors must ensure that `OneConst::ONE` is +/// wherever possible. Implementors must ensure that `ConstOne::ONE` is /// the same value produced by [`One::one()`](trait.One.html#tymethod.one). #[cfg(has_associated_consts)] -pub trait OneConst: One { +pub trait ConstOne: One { /// Multiplicative identity: see [`One::one`](trait.One.html#tymethod.one). const ONE: Self; } @@ -183,7 +183,7 @@ macro_rules! one_impl { macro_rules! one_const_impl { ($t:ty, $v:expr) => { one_impl!($t, $v); - impl OneConst for $t { + impl ConstOne for $t { const ONE: $t = $v; } }; @@ -227,7 +227,7 @@ where } #[cfg(has_associated_consts)] -impl OneConst for Wrapping +impl ConstOne for Wrapping where Wrapping: One, { @@ -254,10 +254,10 @@ fn const_identies() { macro_rules! test_zero_one { ($zero:expr, $one:expr; $($t:ty),+) => { $( - assert_eq!(<$t as ZeroConst>::ZERO, $zero); - assert_eq!(<$t as ZeroConst>::ZERO, <$t as Zero>::zero()); - assert_eq!(<$t as OneConst>::ONE, $one); - assert_eq!(<$t as OneConst>::ONE, <$t as One>::one()); + assert_eq!(<$t as ConstZero>::ZERO, $zero); + assert_eq!(<$t as ConstZero>::ZERO, <$t as Zero>::zero()); + assert_eq!(<$t as ConstOne>::ONE, $one); + assert_eq!(<$t as ConstOne>::ONE, <$t as One>::one()); )+ } } diff --git a/src/lib.rs b/src/lib.rs index 675d6f1..cb36fcc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ pub use float::FloatConst; pub use cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive}; pub use identities::{one, zero, One, Zero}; #[cfg(has_associated_consts)] -pub use identities::{OneConst, ZeroConst}; +pub use identities::{ConstOne, ConstZero}; pub use int::PrimInt; pub use ops::checked::{ CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr, CheckedSub,