nonzero_ext

Trait 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

Source§

type Primitive = i8

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroI16

Source§

type Primitive = i16

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroI32

Source§

type Primitive = i32

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroI64

Source§

type Primitive = i64

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroI128

Source§

type Primitive = i128

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroIsize

Source§

type Primitive = isize

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroU8

Source§

type Primitive = u8

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroU16

Source§

type Primitive = u16

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroU32

Source§

type Primitive = u32

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroU64

Source§

type Primitive = u64

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroU128

Source§

type Primitive = u128

Source§

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

Source§

fn get(self) -> Self::Primitive

Source§

impl NonZero for NonZeroUsize

Source§

type Primitive = usize

Source§

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

Source§

fn get(self) -> Self::Primitive

Implementors§