referrerpolicy=no-referrer-when-downgrade
polkadot_sdk_frame::traits

Trait Saturating

pub trait Saturating {
    // Required methods
    fn saturating_add(self, rhs: Self) -> Self;
    fn saturating_sub(self, rhs: Self) -> Self;
    fn saturating_mul(self, rhs: Self) -> Self;
    fn saturating_pow(self, exp: usize) -> Self;

    // Provided methods
    fn saturating_less_one(self) -> Self
       where Self: One { ... }
    fn saturating_plus_one(self) -> Self
       where Self: One { ... }
    fn saturating_inc(&mut self)
       where Self: One { ... }
    fn saturating_dec(&mut self)
       where Self: One { ... }
    fn saturating_accrue(&mut self, amount: Self)
       where Self: One { ... }
    fn saturating_reduce(&mut self, amount: Self)
       where Self: One { ... }
}
Expand description

Saturating arithmetic operations, returning maximum or minimum values instead of overflowing.

Required Methods§

fn saturating_add(self, rhs: Self) -> Self

Saturating addition. Compute self + rhs, saturating at the numeric bounds instead of overflowing.

fn saturating_sub(self, rhs: Self) -> Self

Saturating subtraction. Compute self - rhs, saturating at the numeric bounds instead of overflowing.

fn saturating_mul(self, rhs: Self) -> Self

Saturating multiply. Compute self * rhs, saturating at the numeric bounds instead of overflowing.

fn saturating_pow(self, exp: usize) -> Self

Saturating exponentiation. Compute self.pow(exp), saturating at the numeric bounds instead of overflowing.

Provided Methods§

fn saturating_less_one(self) -> Self
where Self: One,

Decrement self by one, saturating at zero.

fn saturating_plus_one(self) -> Self
where Self: One,

Increment self by one, saturating at the numeric bounds instead of overflowing.

fn saturating_inc(&mut self)
where Self: One,

Increment self by one, saturating.

fn saturating_dec(&mut self)
where Self: One,

Decrement self by one, saturating at zero.

fn saturating_accrue(&mut self, amount: Self)
where Self: One,

Increment self by some amount, saturating.

fn saturating_reduce(&mut self, amount: Self)
where Self: One,

Decrement self by some amount, saturating at zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl Saturating for FixedI64

§

impl Saturating for FixedI128

§

impl Saturating for FixedU64

§

impl Saturating for FixedU128

§

impl Saturating for PerU16

§

impl Saturating for Perbill

§

impl Saturating for Percent

§

impl Saturating for Permill

§

impl Saturating for Perquintill

§

impl<T> Saturating for T

impl<Balance: Saturating> Saturating for Delegations<Balance>

impl<Balance: Saturating> Saturating for Delegations<Balance>