Trait bigdecimal::One

source ·
pub trait One: Sized + Mul<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

Required Methods§

source

fn one() -> 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 muts.

Provided Methods§

source

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.

source

fn is_one(&self) -> bool
where Self: PartialEq,

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl One for f32

source§

fn one() -> f32

source§

fn is_one(&self) -> bool

source§

impl One for f64

source§

fn one() -> f64

source§

fn is_one(&self) -> bool

source§

impl One for i8

source§

fn one() -> i8

source§

fn is_one(&self) -> bool

source§

impl One for i16

source§

fn one() -> i16

source§

fn is_one(&self) -> bool

source§

impl One for i32

source§

fn one() -> i32

source§

fn is_one(&self) -> bool

source§

impl One for i64

source§

fn one() -> i64

source§

fn is_one(&self) -> bool

source§

impl One for i128

source§

fn one() -> i128

source§

fn is_one(&self) -> bool

source§

impl One for isize

source§

fn one() -> isize

source§

fn is_one(&self) -> bool

source§

impl One for u8

source§

fn one() -> u8

source§

fn is_one(&self) -> bool

source§

impl One for u16

source§

fn one() -> u16

source§

fn is_one(&self) -> bool

source§

impl One for u32

source§

fn one() -> u32

source§

fn is_one(&self) -> bool

source§

impl One for u64

source§

fn one() -> u64

source§

fn is_one(&self) -> bool

source§

impl One for u128

source§

fn one() -> u128

source§

fn is_one(&self) -> bool

source§

impl One for usize

source§

fn one() -> usize

source§

fn is_one(&self) -> bool

source§

impl One for BigInt

source§

fn one() -> BigInt

source§

fn set_one(&mut self)

source§

fn is_one(&self) -> bool

source§

impl One for BigUint

source§

fn one() -> BigUint

source§

fn set_one(&mut self)

source§

fn is_one(&self) -> bool

source§

impl<T> One for Wrapping<T>
where T: One, Wrapping<T>: Mul<Output = Wrapping<T>>,

source§

fn set_one(&mut self)

source§

fn one() -> Wrapping<T>

Implementors§