Zero in num_traits::identities - Rust
Description: Defines an additive identity element for `Self`.
Keywords: rust, rustlang, rust-lang, Zero

# Trait num_traits::identities::Zero

source ·

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

        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 mut`s.

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 usize

source§

#### fn zero() -> usize

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 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§

#### fn zero() -> u128

source§

#### fn is_zero(&self) -> bool

source§

### impl Zero for isize

source§

#### fn zero() -> isize

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§

#### fn zero() -> i128

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 f64

source§

#### fn zero() -> f64

source§

#### fn is_zero(&self) -> bool

source§

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

source§

#### fn is_zero(&self) -> bool

source§

#### fn set_zero(&mut self)

source§

#### fn zero() -> Self

## Implementors§