Trait nonzero_ext::NonZeroAble[][src]

pub trait NonZeroAble {
    type NonZero: NonZero;
    fn as_nonzero(self) -> Option<Self::NonZero>;
}

A trait identifying integral types that have a non-zeroable equivalent.

Associated Types

The concrete non-zero type represented by an implementation of this trait. For example, for u8's implementation, it is NonZeroU8.

Required Methods

Converts the integer to its non-zero equivalent.

Examples

Trying to convert zero

let n: u16 = 0;
assert_eq!(n.as_nonzero(), None);

Converting a non-zero value

let n: usize = 20;
let non0n: NonZeroUsize = n.as_nonzero().expect("should result in a converted value");
assert_eq!(non0n.get(), 20);

Implementations on Foreign Types

impl NonZeroAble for u8
[src]

impl NonZeroAble for u16
[src]

impl NonZeroAble for u32
[src]

impl NonZeroAble for u64
[src]

impl NonZeroAble for u128
[src]

impl NonZeroAble for usize
[src]

Implementors