From 9461cd84f2419a3e645412156f3bf0f01d21542f Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Mon, 19 Feb 2018 15:05:11 -0500 Subject: [PATCH] Add is_one. --- src/identities.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/identities.rs b/src/identities.rs index 14f5ac0..0158a46 100644 --- a/src/identities.rs +++ b/src/identities.rs @@ -79,6 +79,14 @@ pub trait One: Sized + Mul { /// `static mut`s. // FIXME (#5527): This should be an associated constant fn one() -> Self; + + /// Returns `true` if `self` is equal to the multiplicative identity. + /// + /// Compatibility note: this method will be a requirement to implement in the future; new + /// implementors should provide it for future-compatibility. + fn is_one(&self) -> bool where Self: PartialEq { + *self == Self::one() + } } macro_rules! one_impl {