pub trait One: Sized + Mul<Self, Output = Self> {
// Required method
fn one() -> Self;
// Provided methods
fn set_one(&mut self) { ... }
fn is_one(&self) -> bool
where Self: PartialEq { ... }
}
Expand description
Defines a multiplicative identity element for Self
.
§Laws
a * 1 = a ∀ a ∈ Self
1 * a = a ∀ a ∈ Self
Returns the multiplicative identity element of Self
, 1
.
§Purity
This function should return the same result at all times regardless of
external mutable state, for example values stored in TLS or in
static mut
s.
Sets self
to the multiplicative identity element of Self
, 1
.
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.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.