num

Trait Zero

Source
pub trait Zero: Sized + Add<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.

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.

Implementations on Foreign Types§

Source§

impl Zero for f32

Source§

fn zero() -> f32

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 i8

Source§

fn zero() -> i8

Source§

fn is_zero(&self) -> bool

Source§

impl Zero for i16

Source§

fn zero() -> i16

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 i64

Source§

fn zero() -> i64

Source§

fn is_zero(&self) -> bool

Source§

impl Zero for i128

Source§

impl Zero for isize

Source§

impl Zero for u8

Source§

fn zero() -> u8

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 u32

Source§

fn zero() -> u32

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 u128

Source§

impl Zero for usize

Source§

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

Source§

fn is_zero(&self) -> bool

Source§

fn set_zero(&mut self)

Source§

fn zero() -> Wrapping<T>

Implementors§

Source§

impl Zero for BigInt

Source§

impl Zero for BigUint

Source§

impl<T> Zero for Ratio<T>
where T: Clone + Integer,

Source§

impl<T> Zero for Complex<T>
where T: Clone + Num,