Skip to content

Commit

Permalink
Merge #39
Browse files Browse the repository at this point in the history
39: Add is_one. r=cuviper a=clarcharr

Implements the version recommended in #5. That issue should remain open to track the breaking-change version.
  • Loading branch information
bors[bot] committed Feb 23, 2018
2 parents bfd62d4 + 51dad50 commit 3431da8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ pub trait One: Sized + Mul<Self, Output = Self> {
/// `static mut`s.
// FIXME (#5527): This should be an associated constant
fn one() -> Self;

/// Returns `true` if `self` is equal to the multiplicative identity.
///
/// For performance reasons, it's best to implement this manually.
/// After a semver bump, this method will be required, and the
/// `where Self: PartialEq` bound will be removed.
#[inline]
fn is_one(&self) -> bool where Self: PartialEq {
*self == Self::one()
}
}

macro_rules! one_impl {
Expand Down

0 comments on commit 3431da8

Please sign in to comment.