Trait scrypto::prelude::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

§

impl<const N: usize> One for BInt<N>

§

fn one() -> BInt<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BIntD8<N>

§

fn one() -> BIntD8<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BIntD16<N>

§

fn one() -> BIntD16<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BIntD32<N>

§

fn one() -> BIntD32<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BUint<N>

§

fn one() -> BUint<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BUintD8<N>

§

fn one() -> BUintD8<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BUintD16<N>

§

fn one() -> BUintD16<N>

§

fn is_one(&self) -> bool

§

impl<const N: usize> One for BUintD32<N>

§

fn one() -> BUintD32<N>

§

fn is_one(&self) -> bool

Implementors§

source§

impl One for I192

source§

impl One for I256

source§

impl One for I320

source§

impl One for I384

source§

impl One for I448

source§

impl One for I512

source§

impl One for I768

source§

impl One for U192

source§

impl One for U256

source§

impl One for U320

source§

impl One for U384

source§

impl One for U448

source§

impl One for U512

source§

impl One for U768

source§

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