Trait nonzero_ext::NonZero

source ·
pub trait NonZero {
    type Primitive;

    // Required methods
    fn new(n: Self::Primitive) -> Option<Self>
       where Self: Sized;
    fn get(self) -> Self::Primitive;
}
Expand description

A trait identifying a non-zero integral type. It is useful mostly in order to give to genericized helper functions as impl NonZero arguments.

Required Associated Types§

source

type Primitive

The primitive type (e.g. u8) underlying this integral type.

Required Methods§

source

fn new(n: Self::Primitive) -> Option<Self>
where Self: Sized,

Creates a new non-zero object from an integer that might be zero.

source

fn get(self) -> Self::Primitive

Returns the value as a primitive type.

Implementations on Foreign Types§

source§

impl NonZero for NonZeroI8

§

type Primitive = i8

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroI16

§

type Primitive = i16

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroI32

§

type Primitive = i32

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroI64

§

type Primitive = i64

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroI128

§

type Primitive = i128

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroIsize

§

type Primitive = isize

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroU8

§

type Primitive = u8

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroU16

§

type Primitive = u16

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroU32

§

type Primitive = u32

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroU64

§

type Primitive = u64

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroU128

§

type Primitive = u128

source§

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

source§

fn get(self) -> Self::Primitive

source§

impl NonZero for NonZeroUsize

§

type Primitive = usize

source§

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

source§

fn get(self) -> Self::Primitive

Implementors§