Skip to content

Commit

Permalink
Rename to ConstZero/ConstOne and re-export from toplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored and cuviper committed Feb 8, 2024
1 parent 536dcf2 commit bc42b83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait Zero: Sized + Add<Self, Output = Self> {
///
/// Types which impl both this trait and [`PartialEq`] will receive a blanket
/// impl of the [`Zero`] trait.
pub trait ZeroConstant: Zero {
pub trait ConstZero: Zero {
/// The additive identity element of `Self`, `0`.
const ZERO: Self;
}
Expand All @@ -51,7 +51,7 @@ macro_rules! zero_impl {
}
}

impl ZeroConstant for $t {
impl ConstZero for $t {
const ZERO: Self = $v;
}
};
Expand Down Expand Up @@ -91,7 +91,7 @@ where
}
}

impl<T: ZeroConstant> ZeroConstant for Wrapping<T>
impl<T: ConstZero> ConstZero for Wrapping<T>
where
Wrapping<T>: Add<Output = Wrapping<T>>,
{
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait One: Sized + Mul<Self, Output = Self> {
///
/// Types which impl both this trait and [`PartialEq`] will receive a blanket
/// impl of the [`One`] trait.
pub trait OneConstant: One {
pub trait ConstOne: One {
/// The multiplicative identity element of `Self`, `1`.
const ONE: Self;
}
Expand All @@ -159,7 +159,7 @@ macro_rules! one_impl {
}
}

impl OneConstant for $t {
impl ConstOne for $t {
const ONE: Self = $v;
}
};
Expand Down Expand Up @@ -195,7 +195,7 @@ where
}
}

impl<T: OneConstant> OneConstant for Wrapping<T>
impl<T: ConstOne> ConstOne for Wrapping<T>
where
Wrapping<T>: Mul<Output = Wrapping<T>>,
{
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use crate::float::Float;
pub use crate::float::FloatConst;
// pub use real::{FloatCore, Real}; // NOTE: Don't do this, it breaks `use num_traits::*;`.
pub use crate::cast::{cast, AsPrimitive, FromPrimitive, NumCast, ToPrimitive};
pub use crate::identities::{one, zero, One, Zero};
pub use crate::identities::{one, zero, ConstOne, ConstZero, One, Zero};
pub use crate::int::PrimInt;
pub use crate::ops::bytes::{FromBytes, ToBytes};
pub use crate::ops::checked::{
Expand Down

0 comments on commit bc42b83

Please sign in to comment.