NonZero

Trait NonZero 

pub trait NonZero: Copy + Sized {
    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§

type Int: PrimUnsignedInt<NonZero = Self>

The primitive unsigned int correspondant.

Required Methods§

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

Create a non-zero without checking the value.

§Safety

The value must not be zero.

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

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

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", so this trait is not object safe.

Implementations on Foreign Types§

§

impl NonZero for NonZeroU8

§

type Int = u8

§

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

§

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

§

fn get(self) -> Self::Int

§

impl NonZero for NonZeroU16

§

type Int = u16

§

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

§

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

§

fn get(self) -> Self::Int

§

impl NonZero for NonZeroU32

§

type Int = u32

§

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

§

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

§

fn get(self) -> Self::Int

§

impl NonZero for NonZeroU64

§

type Int = u64

§

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

§

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

§

fn get(self) -> Self::Int

§

impl NonZero for NonZeroU128

§

type Int = u128

§

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

§

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

§

fn get(self) -> Self::Int

§

impl NonZero for NonZeroUsize

§

type Int = usize

§

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

§

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

§

fn get(self) -> Self::Int

Implementors§