pub trait Zero: Sized + Add<Self, Output = Self> {
    // Required methods
    fn zero() -> Self;
    fn is_zero(&self) -> bool;

    // Provided method
    fn set_zero(&mut self) { ... }
}
Expand description

Defines an additive identity element for Self.

Laws

a + 0 = a       ∀ a ∈ Self
0 + a = a       ∀ a ∈ Self

Required Methods§

source

fn zero() -> Self

Returns the additive identity element of Self, 0.

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.

source

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.

Provided Methods§

source

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Implementations on Foreign Types§

source§

impl Zero for u32

source§

fn zero() -> u32

source§

fn is_zero(&self) -> bool

source§

impl Zero for u8

source§

fn zero() -> u8

source§

fn is_zero(&self) -> bool

source§

impl Zero for u64

source§

fn zero() -> u64

source§

fn is_zero(&self) -> bool

source§

impl Zero for i8

source§

fn zero() -> i8

source§

fn is_zero(&self) -> bool

source§

impl Zero for f64

source§

fn zero() -> f64

source§

fn is_zero(&self) -> bool

source§

impl Zero for f32

source§

fn zero() -> f32

source§

fn is_zero(&self) -> bool

source§

impl Zero for isize

source§

impl Zero for u128

source§

impl<T> Zero for Wrapping<T>where T: Zero, Wrapping<T>: Add<Wrapping<T>, Output = Wrapping<T>>,

source§

fn is_zero(&self) -> bool

source§

fn set_zero(&mut self)

source§

fn zero() -> Wrapping<T>

source§

impl Zero for i64

source§

fn zero() -> i64

source§

fn is_zero(&self) -> bool

source§

impl Zero for u16

source§

fn zero() -> u16

source§

fn is_zero(&self) -> bool

source§

impl Zero for i32

source§

fn zero() -> i32

source§

fn is_zero(&self) -> bool

source§

impl Zero for i128

source§

impl Zero for usize

source§

impl Zero for i16

source§

fn zero() -> i16

source§

fn is_zero(&self) -> bool

source§

impl Zero for BigInt

source§

fn zero() -> BigInt

source§

fn set_zero(&mut self)

source§

fn is_zero(&self) -> bool

source§

impl Zero for BigUint

source§

fn zero() -> BigUint

source§

fn set_zero(&mut self)

source§

fn is_zero(&self) -> bool

Implementors§