Skip to main content

NonZero

Trait NonZero 

pub trait NonZero: Sized + Copy {
    type Int: PrimUnsignedInt<NonZero = Self>;

    // Required methods
    unsafe fn new_unchecked(n: Self::Int) -> Self;
    fn new(n: Self::Int) -> Option<Self>;
    fn get(self) -> Self::Int;
}
Expand description

Functions for primitive type, which has a non-zero correspondant.

Required Associated Types§

Source

type Int: PrimUnsignedInt<NonZero = Self>

The primitive unsigned int correspondant.

Required Methods§

Source

unsafe fn new_unchecked(n: Self::Int) -> Self

Create a non-zero without checking the value.

§Safety

The value must not be zero.

Source

fn new(n: Self::Int) -> Option<Self>

Create a non-zero if the given value is not zero.

Source

fn get(self) -> Self::Int

Returns the value as the primitive type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NonZero for NonZero<u8>

Source§

impl NonZero for NonZero<u16>

Source§

impl NonZero for NonZero<u32>

Source§

impl NonZero for NonZero<u64>

Source§

impl NonZero for NonZero<u128>

Source§

impl NonZero for NonZero<usize>

Implementors§