(function() { var type_impls = Object.fromEntries([["core",[["
1.28.0 · Source§

impl<T> Binary for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","Binary","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.45.0 (const: unstable) · Source§

impl<T> BitOr<T> for NonZero<T>
where\n T: ZeroablePrimitive + BitOr<Output = T>,

Source§

type Output = NonZero<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: T) -> Self::Output

Performs the | operation. Read more
","BitOr","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.45.0 (const: unstable) · Source§

impl<T> BitOr for NonZero<T>
where\n T: ZeroablePrimitive + BitOr<Output = T>,

Source§

type Output = NonZero<T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
","BitOr","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.45.0 (const: unstable) · Source§

impl<T> BitOrAssign<T> for NonZero<T>
where\n T: ZeroablePrimitive,\n Self: BitOr<T, Output = Self>,

Source§

fn bitor_assign(&mut self, rhs: T)

Performs the |= operation. Read more
","BitOrAssign","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.45.0 (const: unstable) · Source§

impl<T> BitOrAssign for NonZero<T>
where\n T: ZeroablePrimitive,\n Self: BitOr<Output = Self>,

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
","BitOrAssign","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Clone for NonZero<T>
where\n T: ZeroablePrimitive,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)
where\n Self:,

Performs copy-assignment from source. Read more
","Clone","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Debug for NonZero<T>
where\n T: ZeroablePrimitive + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","Debug","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Display for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","Display","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
Source§

impl From<Alignment> for NonZero<usize>

Source§

fn from(align: Alignment) -> NonZero<usize>

Converts to this type from the input type.
","From","core::num::nonzero::NonZeroUsize"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i16>> for NonZero<i128>

Source§

fn from(small: NonZero<i16>) -> Self

Converts NonZero<i16>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i16>> for NonZero<i32>

Source§

fn from(small: NonZero<i16>) -> Self

Converts NonZero<i16>\nto NonZero<i32> losslessly.

\n
","From>","core::num::nonzero::NonZeroI32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i16>> for NonZero<i64>

Source§

fn from(small: NonZero<i16>) -> Self

Converts NonZero<i16>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i16>> for NonZero<isize>

Source§

fn from(small: NonZero<i16>) -> Self

Converts NonZero<i16>\nto NonZero<isize> losslessly.

\n
","From>","core::num::nonzero::NonZeroIsize"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i32>> for NonZero<i128>

Source§

fn from(small: NonZero<i32>) -> Self

Converts NonZero<i32>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i32>> for NonZero<i64>

Source§

fn from(small: NonZero<i32>) -> Self

Converts NonZero<i32>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i64>> for NonZero<i128>

Source§

fn from(small: NonZero<i64>) -> Self

Converts NonZero<i64>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i8>> for NonZero<i128>

Source§

fn from(small: NonZero<i8>) -> Self

Converts NonZero<i8>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i8>> for NonZero<i16>

Source§

fn from(small: NonZero<i8>) -> Self

Converts NonZero<i8>\nto NonZero<i16> losslessly.

\n
","From>","core::num::nonzero::NonZeroI16"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i8>> for NonZero<i32>

Source§

fn from(small: NonZero<i8>) -> Self

Converts NonZero<i8>\nto NonZero<i32> losslessly.

\n
","From>","core::num::nonzero::NonZeroI32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i8>> for NonZero<i64>

Source§

fn from(small: NonZero<i8>) -> Self

Converts NonZero<i8>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<i8>> for NonZero<isize>

Source§

fn from(small: NonZero<i8>) -> Self

Converts NonZero<i8>\nto NonZero<isize> losslessly.

\n
","From>","core::num::nonzero::NonZeroIsize"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<i128>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<i32>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<i32> losslessly.

\n
","From>","core::num::nonzero::NonZeroI32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<i64>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<u128>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<u128> losslessly.

\n
","From>","core::num::nonzero::NonZeroU128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<u32>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<u32> losslessly.

\n
","From>","core::num::nonzero::NonZeroU32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<u64>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<u64> losslessly.

\n
","From>","core::num::nonzero::NonZeroU64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u16>> for NonZero<usize>

Source§

fn from(small: NonZero<u16>) -> Self

Converts NonZero<u16>\nto NonZero<usize> losslessly.

\n
","From>","core::num::nonzero::NonZeroUsize"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u32>> for NonZero<i128>

Source§

fn from(small: NonZero<u32>) -> Self

Converts NonZero<u32>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u32>> for NonZero<i64>

Source§

fn from(small: NonZero<u32>) -> Self

Converts NonZero<u32>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u32>> for NonZero<u128>

Source§

fn from(small: NonZero<u32>) -> Self

Converts NonZero<u32>\nto NonZero<u128> losslessly.

\n
","From>","core::num::nonzero::NonZeroU128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u32>> for NonZero<u64>

Source§

fn from(small: NonZero<u32>) -> Self

Converts NonZero<u32>\nto NonZero<u64> losslessly.

\n
","From>","core::num::nonzero::NonZeroU64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u64>> for NonZero<i128>

Source§

fn from(small: NonZero<u64>) -> Self

Converts NonZero<u64>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u64>> for NonZero<u128>

Source§

fn from(small: NonZero<u64>) -> Self

Converts NonZero<u64>\nto NonZero<u128> losslessly.

\n
","From>","core::num::nonzero::NonZeroU128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<i128>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<i128> losslessly.

\n
","From>","core::num::nonzero::NonZeroI128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<i16>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<i16> losslessly.

\n
","From>","core::num::nonzero::NonZeroI16"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<i32>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<i32> losslessly.

\n
","From>","core::num::nonzero::NonZeroI32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<i64>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<i64> losslessly.

\n
","From>","core::num::nonzero::NonZeroI64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<isize>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<isize> losslessly.

\n
","From>","core::num::nonzero::NonZeroIsize"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<u128>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<u128> losslessly.

\n
","From>","core::num::nonzero::NonZeroU128"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<u16>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<u16> losslessly.

\n
","From>","core::num::nonzero::NonZeroU16"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<u32>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<u32> losslessly.

\n
","From>","core::num::nonzero::NonZeroU32"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<u64>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<u64> losslessly.

\n
","From>","core::num::nonzero::NonZeroU64"],["
1.41.0 (const: unstable) · Source§

impl From<NonZero<u8>> for NonZero<usize>

Source§

fn from(small: NonZero<u8>) -> Self

Converts NonZero<u8>\nto NonZero<usize> losslessly.

\n
","From>","core::num::nonzero::NonZeroUsize"],["
1.35.0 · Source§

impl FromStr for NonZero<i128>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroI128"],["
1.35.0 · Source§

impl FromStr for NonZero<i16>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroI16"],["
1.35.0 · Source§

impl FromStr for NonZero<i32>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroI32"],["
1.35.0 · Source§

impl FromStr for NonZero<i64>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroI64"],["
1.35.0 · Source§

impl FromStr for NonZero<i8>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroI8"],["
1.35.0 · Source§

impl FromStr for NonZero<isize>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroIsize"],["
1.35.0 · Source§

impl FromStr for NonZero<u128>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroU128"],["
1.35.0 · Source§

impl FromStr for NonZero<u16>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroU16"],["
1.35.0 · Source§

impl FromStr for NonZero<u32>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroU32"],["
1.35.0 · Source§

impl FromStr for NonZero<u64>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroU64"],["
1.35.0 · Source§

impl FromStr for NonZero<u8>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroU8"],["
1.35.0 · Source§

impl FromStr for NonZero<usize>

Source§

type Err = ParseIntError

The associated error which can be returned from parsing.
Source§

fn from_str(src: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
","FromStr","core::num::nonzero::NonZeroUsize"],["
1.28.0 · Source§

impl<T> Hash for NonZero<T>
where\n T: ZeroablePrimitive + Hash,

Source§

fn hash<H>(&self, state: &mut H)
where\n H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H: Hasher>(data: &[Self], state: &mut H)
where\n Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
","Hash","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.84.0 · Source§

impl<T> LowerExp for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","LowerExp","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> LowerHex for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","LowerHex","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i128>

Source§

type Output = NonZero<i128>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroI128"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i16>

Source§

type Output = NonZero<i16>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroI16"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i32>

Source§

type Output = NonZero<i32>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroI32"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i64>

Source§

type Output = NonZero<i64>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroI64"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<i8>

Source§

type Output = NonZero<i8>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroI8"],["
1.71.0 (const: unstable) · Source§

impl Neg for NonZero<isize>

Source§

type Output = NonZero<isize>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
","Neg","core::num::nonzero::NonZeroIsize"],["
Source§

impl<T> NonZero<T>
where\n T: ZeroablePrimitive,

1.28.0 (const: 1.47.0) · Source

pub const fn new(n: T) -> Option<Self>

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

\n
1.28.0 (const: 1.28.0) · Source

pub const unsafe fn new_unchecked(n: T) -> Self

Creates a non-zero without checking whether the value is non-zero.\nThis results in undefined behavior if the value is zero.

\n
§Safety
\n

The value must not be zero.

\n
Source

pub fn from_mut(n: &mut T) -> Option<&mut Self>

🔬This is a nightly-only experimental API. (nonzero_from_mut #106290)

Converts a reference to a non-zero mutable reference\nif the referenced value is not zero.

\n
Source

pub unsafe fn from_mut_unchecked(n: &mut T) -> &mut Self

🔬This is a nightly-only experimental API. (nonzero_from_mut #106290)

Converts a mutable reference to a non-zero mutable reference\nwithout checking whether the referenced value is non-zero.\nThis results in undefined behavior if the referenced value is zero.

\n
§Safety
\n

The referenced value must not be zero.

\n
1.28.0 (const: 1.34.0) · Source

pub const fn get(self) -> T

Returns the contained value as a primitive type.

\n
",0,"core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
Source§

impl NonZero<i128>

1.67.0 · Source

pub const BITS: u32 = 128u32

The size of this non-zero integer type in bits.

\n

This value is equal to i128::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<i128>::BITS, i128::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to i128::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i128>::MIN.get(), i128::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to i128::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i128>::MAX.get(), i128::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i128>::new(-1i128)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i128>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i128>::new(0b_01100100)?;\nlet b = NonZero::<i128>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i128>::new(0b_01100100)?;\nlet b = NonZero::<i128>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<i128>::new(0b100_0000)?;\nlet b = NonZero::<i128>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x13f40000000000000000000000004f76i128)?;\nlet m = NonZero::new(0x4f7613f4)?;\n\nassert_eq!(n.rotate_left(16), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x4f7613f4i128)?;\nlet m = NonZero::new(0x13f40000000000000000000000004f76)?;\n\nassert_eq!(n.rotate_right(16), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678901234567890123456789012i128)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x12907856341290785634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678901234567890123456789012i128)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x48091e6a2c48091e6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI128;\nlet n = NonZero::new(0x1Ai128)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroI128::from_be(n), n)\n} else {\n    assert_eq!(NonZeroI128::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI128;\nlet n = NonZero::new(0x1Ai128)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroI128::from_le(n), n)\n} else {\n    assert_eq!(NonZeroI128::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai128)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai128)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee i128::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<i128>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\ni128::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\ni128::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\nlet min = NonZero::new(i128::MIN)?;\nlet min_plus = NonZero::new(i128::MIN + 1)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\ni128::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<u128>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1u128)?;\nlet i_pos = NonZero::new(1i128)?;\nlet i_neg = NonZero::new(-1i128)?;\nlet i_min = NonZero::new(i128::MIN)?;\nlet u_max = NonZero::new(u128::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<i128>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See i128::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<i128>::MAX\nif self == NonZero::<i128>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\nlet min = NonZero::new(i128::MIN)?;\nlet min_plus_one = NonZero::new(i128::MIN + 1)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See i128::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\nlet min = NonZero::new(i128::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<u128>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1i128).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<u128>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2i128)?;\nlet four = NonZero::new(4i128)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<i128>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2i128)?;\nlet four = NonZero::new(4i128)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i128::MAX, or self * rhs < i128::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2i128)?;\nlet four = NonZero::new(4i128)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3i128)?;\nlet twenty_seven = NonZero::new(27i128)?;\nlet half_max = NonZero::new(i128::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<i128>::MIN or NonZero::<i128>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3i128)?;\nlet twenty_seven = NonZero::new(27i128)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroI128"],["
Source§

impl NonZero<i16>

1.67.0 · Source

pub const BITS: u32 = 16u32

The size of this non-zero integer type in bits.

\n

This value is equal to i16::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<i16>::BITS, i16::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to i16::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i16>::MIN.get(), i16::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to i16::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i16>::MAX.get(), i16::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i16>::new(-1i16)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i16>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i16>::new(0b_01100100)?;\nlet b = NonZero::<i16>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i16>::new(0b_01100100)?;\nlet b = NonZero::<i16>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<i16>::new(0b100_0000)?;\nlet b = NonZero::<i16>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(-0x5ffdi16)?;\nlet m = NonZero::new(0x3a)?;\n\nassert_eq!(n.rotate_left(4), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x3ai16)?;\nlet m = NonZero::new(-0x5ffd)?;\n\nassert_eq!(n.rotate_right(4), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234i16)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x3412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234i16)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI16;\nlet n = NonZero::new(0x1Ai16)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroI16::from_be(n), n)\n} else {\n    assert_eq!(NonZeroI16::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI16;\nlet n = NonZero::new(0x1Ai16)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroI16::from_le(n), n)\n} else {\n    assert_eq!(NonZeroI16::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai16)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai16)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee i16::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<i16>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\ni16::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\ni16::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\nlet min = NonZero::new(i16::MIN)?;\nlet min_plus = NonZero::new(i16::MIN + 1)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\ni16::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<u16>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1u16)?;\nlet i_pos = NonZero::new(1i16)?;\nlet i_neg = NonZero::new(-1i16)?;\nlet i_min = NonZero::new(i16::MIN)?;\nlet u_max = NonZero::new(u16::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<i16>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See i16::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<i16>::MAX\nif self == NonZero::<i16>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\nlet min = NonZero::new(i16::MIN)?;\nlet min_plus_one = NonZero::new(i16::MIN + 1)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See i16::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\nlet min = NonZero::new(i16::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<u16>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1i16).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<u16>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2i16)?;\nlet four = NonZero::new(4i16)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<i16>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2i16)?;\nlet four = NonZero::new(4i16)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i16::MAX, or self * rhs < i16::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2i16)?;\nlet four = NonZero::new(4i16)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3i16)?;\nlet twenty_seven = NonZero::new(27i16)?;\nlet half_max = NonZero::new(i16::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<i16>::MIN or NonZero::<i16>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3i16)?;\nlet twenty_seven = NonZero::new(27i16)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroI16"],["
Source§

impl NonZero<i32>

1.67.0 · Source

pub const BITS: u32 = 32u32

The size of this non-zero integer type in bits.

\n

This value is equal to i32::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<i32>::BITS, i32::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to i32::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i32>::MIN.get(), i32::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to i32::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i32>::MAX.get(), i32::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i32>::new(-1i32)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i32>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i32>::new(0b_01100100)?;\nlet b = NonZero::<i32>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i32>::new(0b_01100100)?;\nlet b = NonZero::<i32>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<i32>::new(0b100_0000)?;\nlet b = NonZero::<i32>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x10000b3i32)?;\nlet m = NonZero::new(0xb301)?;\n\nassert_eq!(n.rotate_left(8), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xb301i32)?;\nlet m = NonZero::new(0x10000b3)?;\n\nassert_eq!(n.rotate_right(8), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678i32)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x78563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678i32)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x1e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI32;\nlet n = NonZero::new(0x1Ai32)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroI32::from_be(n), n)\n} else {\n    assert_eq!(NonZeroI32::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI32;\nlet n = NonZero::new(0x1Ai32)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroI32::from_le(n), n)\n} else {\n    assert_eq!(NonZeroI32::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai32)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai32)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee i32::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<i32>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\ni32::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\ni32::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\nlet min = NonZero::new(i32::MIN)?;\nlet min_plus = NonZero::new(i32::MIN + 1)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\ni32::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<u32>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1u32)?;\nlet i_pos = NonZero::new(1i32)?;\nlet i_neg = NonZero::new(-1i32)?;\nlet i_min = NonZero::new(i32::MIN)?;\nlet u_max = NonZero::new(u32::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<i32>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See i32::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<i32>::MAX\nif self == NonZero::<i32>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\nlet min = NonZero::new(i32::MIN)?;\nlet min_plus_one = NonZero::new(i32::MIN + 1)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See i32::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\nlet min = NonZero::new(i32::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<u32>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1i32).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<u32>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2i32)?;\nlet four = NonZero::new(4i32)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<i32>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2i32)?;\nlet four = NonZero::new(4i32)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i32::MAX, or self * rhs < i32::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2i32)?;\nlet four = NonZero::new(4i32)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3i32)?;\nlet twenty_seven = NonZero::new(27i32)?;\nlet half_max = NonZero::new(i32::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<i32>::MIN or NonZero::<i32>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3i32)?;\nlet twenty_seven = NonZero::new(27i32)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroI32"],["
Source§

impl NonZero<i64>

1.67.0 · Source

pub const BITS: u32 = 64u32

The size of this non-zero integer type in bits.

\n

This value is equal to i64::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<i64>::BITS, i64::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to i64::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i64>::MIN.get(), i64::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to i64::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i64>::MAX.get(), i64::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i64>::new(-1i64)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i64>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i64>::new(0b_01100100)?;\nlet b = NonZero::<i64>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i64>::new(0b_01100100)?;\nlet b = NonZero::<i64>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<i64>::new(0b100_0000)?;\nlet b = NonZero::<i64>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xaa00000000006e1i64)?;\nlet m = NonZero::new(0x6e10aa)?;\n\nassert_eq!(n.rotate_left(12), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x6e10aai64)?;\nlet m = NonZero::new(0xaa00000000006e1)?;\n\nassert_eq!(n.rotate_right(12), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456i64)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x5634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456i64)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI64;\nlet n = NonZero::new(0x1Ai64)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroI64::from_be(n), n)\n} else {\n    assert_eq!(NonZeroI64::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI64;\nlet n = NonZero::new(0x1Ai64)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroI64::from_le(n), n)\n} else {\n    assert_eq!(NonZeroI64::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai64)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai64)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee i64::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<i64>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\ni64::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\ni64::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\nlet min = NonZero::new(i64::MIN)?;\nlet min_plus = NonZero::new(i64::MIN + 1)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\ni64::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<u64>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1u64)?;\nlet i_pos = NonZero::new(1i64)?;\nlet i_neg = NonZero::new(-1i64)?;\nlet i_min = NonZero::new(i64::MIN)?;\nlet u_max = NonZero::new(u64::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<i64>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See i64::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<i64>::MAX\nif self == NonZero::<i64>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\nlet min = NonZero::new(i64::MIN)?;\nlet min_plus_one = NonZero::new(i64::MIN + 1)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See i64::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\nlet min = NonZero::new(i64::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<u64>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1i64).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<u64>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2i64)?;\nlet four = NonZero::new(4i64)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<i64>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2i64)?;\nlet four = NonZero::new(4i64)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i64::MAX, or self * rhs < i64::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2i64)?;\nlet four = NonZero::new(4i64)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3i64)?;\nlet twenty_seven = NonZero::new(27i64)?;\nlet half_max = NonZero::new(i64::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<i64>::MIN or NonZero::<i64>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3i64)?;\nlet twenty_seven = NonZero::new(27i64)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroI64"],["
Source§

impl NonZero<i8>

1.67.0 · Source

pub const BITS: u32 = 8u32

The size of this non-zero integer type in bits.

\n

This value is equal to i8::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<i8>::BITS, i8::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to i8::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i8>::MIN.get(), i8::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to i8::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<i8>::MAX.get(), i8::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i8>::new(-1i8)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<i8>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i8>::new(0b_01100100)?;\nlet b = NonZero::<i8>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<i8>::new(0b_01100100)?;\nlet b = NonZero::<i8>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<i8>::new(0b100_0000)?;\nlet b = NonZero::<i8>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(-0x7ei8)?;\nlet m = NonZero::new(0xa)?;\n\nassert_eq!(n.rotate_left(2), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xai8)?;\nlet m = NonZero::new(-0x7e)?;\n\nassert_eq!(n.rotate_right(2), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12i8)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x12)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12i8)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI8;\nlet n = NonZero::new(0x1Ai8)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroI8::from_be(n), n)\n} else {\n    assert_eq!(NonZeroI8::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroI8;\nlet n = NonZero::new(0x1Ai8)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroI8::from_le(n), n)\n} else {\n    assert_eq!(NonZeroI8::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai8)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ai8)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee i8::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<i8>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\ni8::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\ni8::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\nlet min = NonZero::new(i8::MIN)?;\nlet min_plus = NonZero::new(i8::MIN + 1)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\ni8::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<u8>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1u8)?;\nlet i_pos = NonZero::new(1i8)?;\nlet i_neg = NonZero::new(-1i8)?;\nlet i_min = NonZero::new(i8::MIN)?;\nlet u_max = NonZero::new(u8::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<i8>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See i8::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<i8>::MAX\nif self == NonZero::<i8>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\nlet min = NonZero::new(i8::MIN)?;\nlet min_plus_one = NonZero::new(i8::MIN + 1)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See i8::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\nlet min = NonZero::new(i8::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<u8>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1i8).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<u8>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2i8)?;\nlet four = NonZero::new(4i8)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<i8>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2i8)?;\nlet four = NonZero::new(4i8)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i8::MAX, or self * rhs < i8::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2i8)?;\nlet four = NonZero::new(4i8)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3i8)?;\nlet twenty_seven = NonZero::new(27i8)?;\nlet half_max = NonZero::new(i8::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<i8>::MIN or NonZero::<i8>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3i8)?;\nlet twenty_seven = NonZero::new(27i8)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroI8"],["
Source§

impl NonZero<isize>

1.67.0 · Source

pub const BITS: u32 = 64u32

The size of this non-zero integer type in bits.

\n

This value is equal to isize::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<isize>::BITS, isize::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type,\nequal to isize::MIN.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<isize>::MIN.get(), isize::MIN);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to isize::MAX.

\n

Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.

\n
§Examples
\n
assert_eq!(NonZero::<isize>::MAX.get(), isize::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<isize>::new(-1isize)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<isize>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<isize>::new(0b_01100100)?;\nlet b = NonZero::<isize>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<isize>::new(0b_01100100)?;\nlet b = NonZero::<isize>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<isize>::new(0b100_0000)?;\nlet b = NonZero::<isize>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xaa00000000006e1isize)?;\nlet m = NonZero::new(0x6e10aa)?;\n\nassert_eq!(n.rotate_left(12), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x6e10aaisize)?;\nlet m = NonZero::new(0xaa00000000006e1)?;\n\nassert_eq!(n.rotate_right(12), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456isize)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x5634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456isize)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroIsize;\nlet n = NonZero::new(0x1Aisize)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroIsize::from_be(n), n)\n} else {\n    assert_eq!(NonZeroIsize::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroIsize;\nlet n = NonZero::new(0x1Aisize)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroIsize::from_le(n), n)\n} else {\n    assert_eq!(NonZeroIsize::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Aisize)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Aisize)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn abs(self) -> Self

Computes the absolute value of self.\nSee isize::abs\nfor documentation on overflow behavior.

\n
§Example
\n
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\n\nassert_eq!(pos, pos.abs());\nassert_eq!(pos, neg.abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_abs(self) -> Option<Self>

Checked absolute value.\nChecks for overflow and returns None if\nself == NonZero::<isize>::MIN.\nThe result cannot be zero.

\n
§Example
\n
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!(Some(pos), neg.checked_abs());\nassert_eq!(None, min.checked_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn overflowing_abs(self) -> (Self, bool)

Computes the absolute value of self,\nwith overflow information, see\nisize::overflowing_abs.

\n
§Example
\n
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!((pos, false), pos.overflowing_abs());\nassert_eq!((pos, false), neg.overflowing_abs());\nassert_eq!((min, true), min.overflowing_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_abs(self) -> Self

Saturating absolute value, see\nisize::saturating_abs.

\n
§Example
\n
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\nlet min = NonZero::new(isize::MIN)?;\nlet min_plus = NonZero::new(isize::MIN + 1)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn wrapping_abs(self) -> Self

Wrapping absolute value, see\nisize::wrapping_abs.

\n
§Example
\n
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!(pos, pos.wrapping_abs());\nassert_eq!(pos, neg.wrapping_abs());\nassert_eq!(min, min.wrapping_abs());\nassert_eq!(max, (-max).wrapping_abs());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn unsigned_abs(self) -> NonZero<usize>

Computes the absolute value of self\nwithout any wrapping or panicking.

\n
§Example
\n
let u_pos = NonZero::new(1usize)?;\nlet i_pos = NonZero::new(1isize)?;\nlet i_neg = NonZero::new(-1isize)?;\nlet i_min = NonZero::new(isize::MIN)?;\nlet u_max = NonZero::new(usize::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the\nnumber is negative.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\n\nassert!(pos_five.is_positive());\nassert!(!neg_five.is_positive());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the\nnumber is positive.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\n\nassert!(neg_five.is_negative());\nassert!(!pos_five.is_negative());
\n
1.71.0 (const: 1.71.0) · Source

pub const fn checked_neg(self) -> Option<Self>

Checked negation. Computes -self,\nreturning None if self == NonZero::<isize>::MIN.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!(pos_five.checked_neg(), Some(neg_five));\nassert_eq!(min.checked_neg(), None);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn overflowing_neg(self) -> (Self, bool)

Negates self, overflowing if this is equal to the minimum value.

\n

See isize::overflowing_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!(pos_five.overflowing_neg(), (neg_five, false));\nassert_eq!(min.overflowing_neg(), (min, true));
\n
1.71.0 (const: 1.71.0) · Source

pub const fn saturating_neg(self) -> Self

Saturating negation. Computes -self,\nreturning NonZero::<isize>::MAX\nif self == NonZero::<isize>::MIN\ninstead of overflowing.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\nlet min = NonZero::new(isize::MIN)?;\nlet min_plus_one = NonZero::new(isize::MIN + 1)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);
\n
1.71.0 (const: 1.71.0) · Source

pub const fn wrapping_neg(self) -> Self

Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.

\n

See isize::wrapping_neg\nfor documentation on overflow behavior.

\n
§Example
\n
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\nlet min = NonZero::new(isize::MIN)?;\n\nassert_eq!(pos_five.wrapping_neg(), neg_five);\nassert_eq!(min.wrapping_neg(), min);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_unsigned(self) -> NonZero<usize>

Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::new(-1isize).unwrap();\n\nassert_eq!(n.cast_unsigned(), NonZero::<usize>::MAX);
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2isize)?;\nlet four = NonZero::new(4isize)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<isize>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2isize)?;\nlet four = NonZero::new(4isize)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > isize::MAX, or self * rhs < isize::MIN.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2isize)?;\nlet four = NonZero::new(4isize)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3isize)?;\nlet twenty_seven = NonZero::new(27isize)?;\nlet half_max = NonZero::new(isize::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<isize>::MIN or NonZero::<isize>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3isize)?;\nlet twenty_seven = NonZero::new(27isize)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroIsize"],["
Source§

impl NonZero<u128>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1u128).unwrap();\nlet max = NonZero::new(u128::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2u128).unwrap();\nlet three = NonZero::new(3u128).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroU128"],["
Source§

impl NonZero<u128>

1.67.0 · Source

pub const BITS: u32 = 128u32

The size of this non-zero integer type in bits.

\n

This value is equal to u128::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<u128>::BITS, u128::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<u128>::MIN.get(), 1u128);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to u128::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<u128>::MAX.get(), u128::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u128>::new(u128::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u128>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u128>::new(0b_01100100)?;\nlet b = NonZero::<u128>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u128>::new(0b_01100100)?;\nlet b = NonZero::<u128>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<u128>::new(0b100_0000)?;\nlet b = NonZero::<u128>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x13f40000000000000000000000004f76u128)?;\nlet m = NonZero::new(0x4f7613f4)?;\n\nassert_eq!(n.rotate_left(16), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x4f7613f4u128)?;\nlet m = NonZero::new(0x13f40000000000000000000000004f76)?;\n\nassert_eq!(n.rotate_right(16), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678901234567890123456789012u128)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x12907856341290785634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678901234567890123456789012u128)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x48091e6a2c48091e6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU128;\nlet n = NonZero::new(0x1Au128)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroU128::from_be(n), n)\n} else {\n    assert_eq!(NonZeroU128::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU128;\nlet n = NonZero::new(0x1Au128)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroU128::from_le(n), n)\n} else {\n    assert_eq!(NonZeroU128::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au128)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au128)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: u128) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1u128)?;\nlet two = NonZero::new(2u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: u128) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<u128>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1u128)?;\nlet two = NonZero::new(2u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: u128) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u128::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1u128)?;\nlet two = NonZero::new(2u128)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u128)?;\nlet three = NonZero::new(3u128)?;\nlet four = NonZero::new(4u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nu128::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7u128)?.ilog2(), 2);\nassert_eq!(NonZero::new(8u128)?.ilog2(), 3);\nassert_eq!(NonZero::new(9u128)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nu128::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99u128)?.ilog10(), 1);\nassert_eq!(NonZero::new(100u128)?.ilog10(), 2);\nassert_eq!(NonZero::new(101u128)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1u128)?;\nlet two = NonZero::new(2u128)?;\nlet four = NonZero::new(4u128)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8u128)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10u128)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10u128)?;\nlet three = NonZero::new(3u128)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<i128>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<u128>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1i128).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u128)?;\nlet four = NonZero::new(4u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<u128>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2u128)?;\nlet four = NonZero::new(4u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u128::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2u128)?;\nlet four = NonZero::new(4u128)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3u128)?;\nlet twenty_seven = NonZero::new(27u128)?;\nlet half_max = NonZero::new(u128::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<u128>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3u128)?;\nlet twenty_seven = NonZero::new(27u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroU128"],["
Source§

impl NonZero<u16>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1u16).unwrap();\nlet max = NonZero::new(u16::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2u16).unwrap();\nlet three = NonZero::new(3u16).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroU16"],["
Source§

impl NonZero<u16>

1.67.0 · Source

pub const BITS: u32 = 16u32

The size of this non-zero integer type in bits.

\n

This value is equal to u16::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<u16>::BITS, u16::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<u16>::MIN.get(), 1u16);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to u16::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<u16>::MAX.get(), u16::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u16>::new(u16::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u16>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u16>::new(0b_01100100)?;\nlet b = NonZero::<u16>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u16>::new(0b_01100100)?;\nlet b = NonZero::<u16>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<u16>::new(0b100_0000)?;\nlet b = NonZero::<u16>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xa003u16)?;\nlet m = NonZero::new(0x3a)?;\n\nassert_eq!(n.rotate_left(4), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x3au16)?;\nlet m = NonZero::new(0xa003)?;\n\nassert_eq!(n.rotate_right(4), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234u16)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x3412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234u16)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU16;\nlet n = NonZero::new(0x1Au16)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroU16::from_be(n), n)\n} else {\n    assert_eq!(NonZeroU16::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU16;\nlet n = NonZero::new(0x1Au16)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroU16::from_le(n), n)\n} else {\n    assert_eq!(NonZeroU16::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au16)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au16)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: u16) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1u16)?;\nlet two = NonZero::new(2u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: u16) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<u16>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1u16)?;\nlet two = NonZero::new(2u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: u16) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u16::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1u16)?;\nlet two = NonZero::new(2u16)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u16)?;\nlet three = NonZero::new(3u16)?;\nlet four = NonZero::new(4u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nu16::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7u16)?.ilog2(), 2);\nassert_eq!(NonZero::new(8u16)?.ilog2(), 3);\nassert_eq!(NonZero::new(9u16)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nu16::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99u16)?.ilog10(), 1);\nassert_eq!(NonZero::new(100u16)?.ilog10(), 2);\nassert_eq!(NonZero::new(101u16)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1u16)?;\nlet two = NonZero::new(2u16)?;\nlet four = NonZero::new(4u16)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8u16)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10u16)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10u16)?;\nlet three = NonZero::new(3u16)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<i16>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<u16>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1i16).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u16)?;\nlet four = NonZero::new(4u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<u16>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2u16)?;\nlet four = NonZero::new(4u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u16::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2u16)?;\nlet four = NonZero::new(4u16)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3u16)?;\nlet twenty_seven = NonZero::new(27u16)?;\nlet half_max = NonZero::new(u16::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<u16>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3u16)?;\nlet twenty_seven = NonZero::new(27u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroU16"],["
Source§

impl NonZero<u32>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1u32).unwrap();\nlet max = NonZero::new(u32::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2u32).unwrap();\nlet three = NonZero::new(3u32).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroU32"],["
Source§

impl NonZero<u32>

1.67.0 · Source

pub const BITS: u32 = 32u32

The size of this non-zero integer type in bits.

\n

This value is equal to u32::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<u32>::BITS, u32::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<u32>::MIN.get(), 1u32);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to u32::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<u32>::MAX.get(), u32::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u32>::new(u32::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u32>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u32>::new(0b_01100100)?;\nlet b = NonZero::<u32>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u32>::new(0b_01100100)?;\nlet b = NonZero::<u32>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<u32>::new(0b100_0000)?;\nlet b = NonZero::<u32>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x10000b3u32)?;\nlet m = NonZero::new(0xb301)?;\n\nassert_eq!(n.rotate_left(8), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xb301u32)?;\nlet m = NonZero::new(0x10000b3)?;\n\nassert_eq!(n.rotate_right(8), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678u32)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x78563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12345678u32)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x1e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU32;\nlet n = NonZero::new(0x1Au32)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroU32::from_be(n), n)\n} else {\n    assert_eq!(NonZeroU32::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU32;\nlet n = NonZero::new(0x1Au32)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroU32::from_le(n), n)\n} else {\n    assert_eq!(NonZeroU32::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au32)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au32)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: u32) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1u32)?;\nlet two = NonZero::new(2u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: u32) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<u32>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1u32)?;\nlet two = NonZero::new(2u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u32::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1u32)?;\nlet two = NonZero::new(2u32)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u32)?;\nlet three = NonZero::new(3u32)?;\nlet four = NonZero::new(4u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nu32::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7u32)?.ilog2(), 2);\nassert_eq!(NonZero::new(8u32)?.ilog2(), 3);\nassert_eq!(NonZero::new(9u32)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nu32::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99u32)?.ilog10(), 1);\nassert_eq!(NonZero::new(100u32)?.ilog10(), 2);\nassert_eq!(NonZero::new(101u32)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1u32)?;\nlet two = NonZero::new(2u32)?;\nlet four = NonZero::new(4u32)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8u32)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10u32)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10u32)?;\nlet three = NonZero::new(3u32)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<i32>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<u32>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1i32).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u32)?;\nlet four = NonZero::new(4u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<u32>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2u32)?;\nlet four = NonZero::new(4u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u32::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2u32)?;\nlet four = NonZero::new(4u32)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3u32)?;\nlet twenty_seven = NonZero::new(27u32)?;\nlet half_max = NonZero::new(u32::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<u32>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3u32)?;\nlet twenty_seven = NonZero::new(27u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroU32"],["
Source§

impl NonZero<u64>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1u64).unwrap();\nlet max = NonZero::new(u64::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2u64).unwrap();\nlet three = NonZero::new(3u64).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroU64"],["
Source§

impl NonZero<u64>

1.67.0 · Source

pub const BITS: u32 = 64u32

The size of this non-zero integer type in bits.

\n

This value is equal to u64::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<u64>::BITS, u64::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<u64>::MIN.get(), 1u64);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to u64::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<u64>::MAX.get(), u64::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u64>::new(u64::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u64>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u64>::new(0b_01100100)?;\nlet b = NonZero::<u64>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u64>::new(0b_01100100)?;\nlet b = NonZero::<u64>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<u64>::new(0b100_0000)?;\nlet b = NonZero::<u64>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xaa00000000006e1u64)?;\nlet m = NonZero::new(0x6e10aa)?;\n\nassert_eq!(n.rotate_left(12), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x6e10aau64)?;\nlet m = NonZero::new(0xaa00000000006e1)?;\n\nassert_eq!(n.rotate_right(12), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456u64)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x5634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456u64)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU64;\nlet n = NonZero::new(0x1Au64)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroU64::from_be(n), n)\n} else {\n    assert_eq!(NonZeroU64::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU64;\nlet n = NonZero::new(0x1Au64)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroU64::from_le(n), n)\n} else {\n    assert_eq!(NonZeroU64::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au64)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au64)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: u64) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1u64)?;\nlet two = NonZero::new(2u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: u64) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<u64>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1u64)?;\nlet two = NonZero::new(2u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: u64) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u64::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1u64)?;\nlet two = NonZero::new(2u64)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u64)?;\nlet three = NonZero::new(3u64)?;\nlet four = NonZero::new(4u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nu64::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7u64)?.ilog2(), 2);\nassert_eq!(NonZero::new(8u64)?.ilog2(), 3);\nassert_eq!(NonZero::new(9u64)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nu64::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99u64)?.ilog10(), 1);\nassert_eq!(NonZero::new(100u64)?.ilog10(), 2);\nassert_eq!(NonZero::new(101u64)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1u64)?;\nlet two = NonZero::new(2u64)?;\nlet four = NonZero::new(4u64)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8u64)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10u64)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10u64)?;\nlet three = NonZero::new(3u64)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<i64>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<u64>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1i64).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u64)?;\nlet four = NonZero::new(4u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<u64>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2u64)?;\nlet four = NonZero::new(4u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u64::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2u64)?;\nlet four = NonZero::new(4u64)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3u64)?;\nlet twenty_seven = NonZero::new(27u64)?;\nlet half_max = NonZero::new(u64::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<u64>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3u64)?;\nlet twenty_seven = NonZero::new(27u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroU64"],["
Source§

impl NonZero<u8>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1u8).unwrap();\nlet max = NonZero::new(u8::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2u8).unwrap();\nlet three = NonZero::new(3u8).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroU8"],["
Source§

impl NonZero<u8>

1.67.0 · Source

pub const BITS: u32 = 8u32

The size of this non-zero integer type in bits.

\n

This value is equal to u8::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<u8>::BITS, u8::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<u8>::MIN.get(), 1u8);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to u8::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<u8>::MAX.get(), u8::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u8>::new(u8::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<u8>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u8>::new(0b_01100100)?;\nlet b = NonZero::<u8>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<u8>::new(0b_01100100)?;\nlet b = NonZero::<u8>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<u8>::new(0b100_0000)?;\nlet b = NonZero::<u8>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x82u8)?;\nlet m = NonZero::new(0xa)?;\n\nassert_eq!(n.rotate_left(2), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xau8)?;\nlet m = NonZero::new(0x82)?;\n\nassert_eq!(n.rotate_right(2), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12u8)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x12)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x12u8)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU8;\nlet n = NonZero::new(0x1Au8)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroU8::from_be(n), n)\n} else {\n    assert_eq!(NonZeroU8::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroU8;\nlet n = NonZero::new(0x1Au8)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroU8::from_le(n), n)\n} else {\n    assert_eq!(NonZeroU8::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au8)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Au8)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: u8) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1u8)?;\nlet two = NonZero::new(2u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: u8) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<u8>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1u8)?;\nlet two = NonZero::new(2u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: u8) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u8::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1u8)?;\nlet two = NonZero::new(2u8)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u8)?;\nlet three = NonZero::new(3u8)?;\nlet four = NonZero::new(4u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nu8::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7u8)?.ilog2(), 2);\nassert_eq!(NonZero::new(8u8)?.ilog2(), 3);\nassert_eq!(NonZero::new(9u8)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nu8::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99u8)?.ilog10(), 1);\nassert_eq!(NonZero::new(100u8)?.ilog10(), 2);\nassert_eq!(NonZero::new(101u8)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1u8)?;\nlet two = NonZero::new(2u8)?;\nlet four = NonZero::new(4u8)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8u8)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10u8)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10u8)?;\nlet three = NonZero::new(3u8)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<i8>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<u8>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1i8).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2u8)?;\nlet four = NonZero::new(4u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<u8>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2u8)?;\nlet four = NonZero::new(4u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u8::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2u8)?;\nlet four = NonZero::new(4u8)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3u8)?;\nlet twenty_seven = NonZero::new(27u8)?;\nlet half_max = NonZero::new(u8::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<u8>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3u8)?;\nlet twenty_seven = NonZero::new(27u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroU8"],["
Source§

impl NonZero<usize>

Source

pub const fn div_ceil(self, rhs: Self) -> Self

🔬This is a nightly-only experimental API. (unsigned_nonzero_div_ceil #132968)

Calculates the quotient of self and rhs, rounding the result towards positive infinity.

\n

The result is guaranteed to be non-zero.

\n
§Examples
\n
let one = NonZero::new(1usize).unwrap();\nlet max = NonZero::new(usize::MAX).unwrap();\nassert_eq!(one.div_ceil(max), one);\n\nlet two = NonZero::new(2usize).unwrap();\nlet three = NonZero::new(3usize).unwrap();\nassert_eq!(three.div_ceil(two), two);
\n
",0,"core::num::nonzero::NonZeroUsize"],["
Source§

impl NonZero<usize>

1.67.0 · Source

pub const BITS: u32 = 64u32

The size of this non-zero integer type in bits.

\n

This value is equal to usize::BITS.

\n
§Examples
\n
assert_eq!(NonZero::<usize>::BITS, usize::BITS);
\n
1.70.0 · Source

pub const MIN: Self

The smallest value that can be represented by this non-zero\ninteger type, 1.

\n
§Examples
\n
assert_eq!(NonZero::<usize>::MIN.get(), 1usize);
\n
1.70.0 · Source

pub const MAX: Self

The largest value that can be represented by this non-zero\ninteger type,\nequal to usize::MAX.

\n
§Examples
\n
assert_eq!(NonZero::<usize>::MAX.get(), usize::MAX);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn leading_zeros(self) -> u32

Returns the number of leading zeros in the binary representation of self.

\n

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<usize>::new(usize::MAX)?;\n\nassert_eq!(n.leading_zeros(), 0);
\n
1.53.0 (const: 1.53.0) · Source

pub const fn trailing_zeros(self) -> u32

Returns the number of trailing zeros in the binary representation\nof self.

\n

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let n = NonZero::<usize>::new(0b0101000)?;\n\nassert_eq!(n.trailing_zeros(), 3);
\n
Source

pub const fn isolate_highest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the most significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<usize>::new(0b_01100100)?;\nlet b = NonZero::<usize>::new(0b_01000000)?;\n\nassert_eq!(a.isolate_highest_one(), b);
\n
Source

pub const fn isolate_lowest_one(self) -> Self

🔬This is a nightly-only experimental API. (isolate_most_least_significant_one #136909)

Returns self with only the least significant bit set.

\n
§Example
\n
#![feature(isolate_most_least_significant_one)]\n\nlet a = NonZero::<usize>::new(0b_01100100)?;\nlet b = NonZero::<usize>::new(0b_00000100)?;\n\nassert_eq!(a.isolate_lowest_one(), b);
\n
1.86.0 (const: 1.86.0) · Source

pub const fn count_ones(self) -> NonZero<u32>

Returns the number of ones in the binary representation of self.

\n
§Examples
\n
let a = NonZero::<usize>::new(0b100_0000)?;\nlet b = NonZero::<usize>::new(0b100_0011)?;\n\nassert_eq!(a.count_ones(), NonZero::new(1)?);\nassert_eq!(b.count_ones(), NonZero::new(3)?);
\n
Source

pub const fn rotate_left(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.

\n

Please note this isn’t the same operation as the << shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0xaa00000000006e1usize)?;\nlet m = NonZero::new(0x6e10aa)?;\n\nassert_eq!(n.rotate_left(12), m);
\n
Source

pub const fn rotate_right(self, n: u32) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.

\n

Please note this isn’t the same operation as the >> shifting operator!

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x6e10aausize)?;\nlet m = NonZero::new(0xaa00000000006e1)?;\n\nassert_eq!(n.rotate_right(12), m);
\n
Source

pub const fn swap_bytes(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the byte order of the integer.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456usize)?;\nlet m = n.swap_bytes();\n\nassert_eq!(m, NonZero::new(0x5634129078563412)?);
\n
Source

pub const fn reverse_bits(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1234567890123456usize)?;\nlet m = n.reverse_bits();\n\nassert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
\n
Source

pub const fn from_be(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from big endian to the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroUsize;\nlet n = NonZero::new(0x1Ausize)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(NonZeroUsize::from_be(n), n)\n} else {\n    assert_eq!(NonZeroUsize::from_be(n), n.swap_bytes())\n}
\n
Source

pub const fn from_le(x: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts an integer from little endian to the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nuse std::num::NonZeroUsize;\nlet n = NonZero::new(0x1Ausize)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(NonZeroUsize::from_le(n), n)\n} else {\n    assert_eq!(NonZeroUsize::from_le(n), n.swap_bytes())\n}
\n
Source

pub const fn to_be(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to big endian from the target’s endianness.

\n

On big endian this is a no-op. On little endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ausize)?;\n\nif cfg!(target_endian = \"big\") {\n    assert_eq!(n.to_be(), n)\n} else {\n    assert_eq!(n.to_be(), n.swap_bytes())\n}
\n
Source

pub const fn to_le(self) -> Self

🔬This is a nightly-only experimental API. (nonzero_bitwise #128281)

Converts self to little endian from the target’s endianness.

\n

On little endian this is a no-op. On big endian the bytes are\nswapped.

\n
§Examples
\n
#![feature(nonzero_bitwise)]\nlet n = NonZero::new(0x1Ausize)?;\n\nif cfg!(target_endian = \"little\") {\n    assert_eq!(n.to_le(), n)\n} else {\n    assert_eq!(n.to_le(), n.swap_bytes())\n}
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_add(self, other: usize) -> Option<Self>

Adds an unsigned integer to a non-zero value.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let one = NonZero::new(1usize)?;\nlet two = NonZero::new(2usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(Some(two), one.checked_add(1));\nassert_eq!(None, max.checked_add(1));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_add(self, other: usize) -> Self

Adds an unsigned integer to a non-zero value.\nReturn NonZero::<usize>::MAX on overflow.

\n
§Examples
\n
let one = NonZero::new(1usize)?;\nlet two = NonZero::new(2usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(two, one.saturating_add(1));\nassert_eq!(max, max.saturating_add(1));
\n
Source

pub const unsafe fn unchecked_add(self, other: usize) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > usize::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet one = NonZero::new(1usize)?;\nlet two = NonZero::new(2usize)?;\n\nassert_eq!(two, unsafe { one.unchecked_add(1) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_next_power_of_two(self) -> Option<Self>

Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2usize)?;\nlet three = NonZero::new(3usize)?;\nlet four = NonZero::new(4usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

\n

This is the same operation as\nusize::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(7usize)?.ilog2(), 2);\nassert_eq!(NonZero::new(8usize)?.ilog2(), 3);\nassert_eq!(NonZero::new(9usize)?.ilog2(), 3);
\n
1.67.0 (const: 1.67.0) · Source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

\n

This is the same operation as\nusize::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.

\n
§Examples
\n
assert_eq!(NonZero::new(99usize)?.ilog10(), 1);\nassert_eq!(NonZero::new(100usize)?.ilog10(), 2);\nassert_eq!(NonZero::new(101usize)?.ilog10(), 2);
\n
1.85.0 (const: 1.85.0) · Source

pub const fn midpoint(self, rhs: Self) -> Self

Calculates the midpoint (average) between self and rhs.

\n

midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.

\n
§Examples
\n
let one = NonZero::new(1usize)?;\nlet two = NonZero::new(2usize)?;\nlet four = NonZero::new(4usize)?;\n\nassert_eq!(one.midpoint(four), two);\nassert_eq!(four.midpoint(one), two);
\n
1.59.0 (const: 1.59.0) · Source

pub const fn is_power_of_two(self) -> bool

Returns true if and only if self == (1 << k) for some k.

\n

On many architectures, this function can perform better than is_power_of_two()\non the underlying integer type, as special handling of zero can be avoided.

\n
§Examples
\n
let eight = NonZero::new(8usize)?;\nassert!(eight.is_power_of_two());\nlet ten = NonZero::new(10usize)?;\nassert!(!ten.is_power_of_two());
\n
1.84.0 (const: 1.84.0) · Source

pub const fn isqrt(self) -> Self

Returns the square root of the number, rounded down.

\n
§Examples
\n
let ten = NonZero::new(10usize)?;\nlet three = NonZero::new(3usize)?;\n\nassert_eq!(ten.isqrt(), three);
\n
1.87.0 (const: 1.87.0) · Source

pub const fn cast_signed(self) -> NonZero<isize>

Returns the bit pattern of self reinterpreted as a signed integer of the same size.

\n
§Examples
\n
\nlet n = NonZero::<usize>::MAX;\n\nassert_eq!(n.cast_signed(), NonZero::new(-1isize).unwrap());
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_mul(self, other: Self) -> Option<Self>

Multiplies two non-zero integers together.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let two = NonZero::new(2usize)?;\nlet four = NonZero::new(4usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(Some(four), two.checked_mul(two));\nassert_eq!(None, max.checked_mul(two));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.\nReturn NonZero::<usize>::MAX on overflow.

\n
§Examples
\n
let two = NonZero::new(2usize)?;\nlet four = NonZero::new(4usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(four, two.saturating_mul(two));\nassert_eq!(max, four.saturating_mul(max));
\n
Source

pub const unsafe fn unchecked_mul(self, other: Self) -> Self

🔬This is a nightly-only experimental API. (nonzero_ops #84186)

Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > usize::MAX.

\n
§Examples
\n
#![feature(nonzero_ops)]\n\nlet two = NonZero::new(2usize)?;\nlet four = NonZero::new(4usize)?;\n\nassert_eq!(four, unsafe { two.unchecked_mul(two) });
\n
1.64.0 (const: 1.64.0) · Source

pub const fn checked_pow(self, other: u32) -> Option<Self>

Raises non-zero value to an integer power.\nChecks for overflow and returns None on overflow.\nAs a consequence, the result cannot wrap to zero.

\n
§Examples
\n
let three = NonZero::new(3usize)?;\nlet twenty_seven = NonZero::new(27usize)?;\nlet half_max = NonZero::new(usize::MAX / 2)?;\n\nassert_eq!(Some(twenty_seven), three.checked_pow(3));\nassert_eq!(None, half_max.checked_pow(3));
\n
1.64.0 (const: 1.64.0) · Source

pub const fn saturating_pow(self, other: u32) -> Self

Raise non-zero value to an integer power.\nReturn NonZero::<usize>::MAX on overflow.

\n
§Examples
\n
let three = NonZero::new(3usize)?;\nlet twenty_seven = NonZero::new(27usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(twenty_seven, three.saturating_pow(3));\nassert_eq!(max, max.saturating_pow(3));
\n
",0,"core::num::nonzero::NonZeroUsize"],["
1.28.0 · Source§

impl<T> Octal for NonZero<T>
where\n T: ZeroablePrimitive + Octal,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","Octal","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Ord for NonZero<T>
where\n T: ZeroablePrimitive + Ord,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

fn max(self, other: Self) -> Self

Compares and returns the maximum of two values. Read more
Source§

fn min(self, other: Self) -> Self

Compares and returns the minimum of two values. Read more
Source§

fn clamp(self, min: Self, max: Self) -> Self

Restrict a value to a certain interval. Read more
","Ord","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 (const: unstable) · Source§

impl<T> PartialEq for NonZero<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &Self) -> bool

Tests for !=. The default implementation is almost always sufficient,\nand should not be overridden without very good reason.
","PartialEq","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> PartialOrd for NonZero<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &Self) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &Self) -> bool

Tests less than or equal to (for self and other) and is used by the\n<= operator. Read more
Source§

fn gt(&self, other: &Self) -> bool

Tests greater than (for self and other) and is used by the >\noperator. Read more
Source§

fn ge(&self, other: &Self) -> bool

Tests greater than or equal to (for self and other) and is used by\nthe >= operator. Read more
","PartialOrd","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<i16>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<i32>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<i64>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<i8>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<isize>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<u128>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<u16>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<u32>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<u64>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<u8>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i128>> for NonZero<usize>

Source§

fn try_from(value: NonZero<i128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i128>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<i8>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<u128>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<u16>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<u32>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<u64>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<u8>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i16>> for NonZero<usize>

Source§

fn try_from(value: NonZero<i16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i16>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<i16>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<i8>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<isize>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<u128>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<u16>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<u32>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<u64>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<u8>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i32>> for NonZero<usize>

Source§

fn try_from(value: NonZero<i32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i32>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<i16>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<i32>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<i8>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<isize>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<u128>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<u16>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<u32>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<u64>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<u8>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i64>> for NonZero<usize>

Source§

fn try_from(value: NonZero<i64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i64>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<u128>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<u16>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<u32>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<u64>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<u8>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<i8>> for NonZero<usize>

Source§

fn try_from(value: NonZero<i8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<i8>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<i128>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<i128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<i16>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<i32>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<i64>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<i8>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<u128>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<u16>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<u32>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<u64>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<u8>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<isize>> for NonZero<usize>

Source§

fn try_from(value: NonZero<isize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<isize>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<i128>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<i128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<i16>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<i32>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<i64>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<i8>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<isize>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<u16>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<u32>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<u64>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<u8>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u128>> for NonZero<usize>

Source§

fn try_from(value: NonZero<u128>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u128>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u16>> for NonZero<i16>

Source§

fn try_from(value: NonZero<u16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u16>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u16>> for NonZero<i8>

Source§

fn try_from(value: NonZero<u16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u16>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u16>> for NonZero<isize>

Source§

fn try_from(value: NonZero<u16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u16>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u16>> for NonZero<u8>

Source§

fn try_from(value: NonZero<u16>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u16>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<i16>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<i32>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<i8>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<isize>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<u16>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<u8>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u32>> for NonZero<usize>

Source§

fn try_from(value: NonZero<u32>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u32>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<i16>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<i32>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<i64>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<i8>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<isize>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<u16>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<u32>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<u8>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u64>> for NonZero<usize>

Source§

fn try_from(value: NonZero<u64>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u64>\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroUsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<u8>> for NonZero<i8>

Source§

fn try_from(value: NonZero<u8>) -> Result<Self, Self::Error>

Attempts to convert NonZero<u8>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<i128>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<i128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<i16>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<i32>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<i64>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<i8>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroI8"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<isize>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroIsize"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<u128>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU128"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<u16>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU16"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<u32>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU32"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<u64>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU64"],["
1.49.0 (const: unstable) · Source§

impl TryFrom<NonZero<usize>> for NonZero<u8>

Source§

fn try_from(value: NonZero<usize>) -> Result<Self, Self::Error>

Attempts to convert NonZero<usize>\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom>","core::num::nonzero::NonZeroU8"],["
1.46.0 · Source§

impl TryFrom<i128> for NonZero<i128>

Source§

fn try_from(value: i128) -> Result<Self, Self::Error>

Attempts to convert i128\nto NonZero<i128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroI128"],["
1.46.0 · Source§

impl TryFrom<i16> for NonZero<i16>

Source§

fn try_from(value: i16) -> Result<Self, Self::Error>

Attempts to convert i16\nto NonZero<i16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroI16"],["
1.46.0 · Source§

impl TryFrom<i32> for NonZero<i32>

Source§

fn try_from(value: i32) -> Result<Self, Self::Error>

Attempts to convert i32\nto NonZero<i32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroI32"],["
1.46.0 · Source§

impl TryFrom<i64> for NonZero<i64>

Source§

fn try_from(value: i64) -> Result<Self, Self::Error>

Attempts to convert i64\nto NonZero<i64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroI64"],["
1.46.0 · Source§

impl TryFrom<i8> for NonZero<i8>

Source§

fn try_from(value: i8) -> Result<Self, Self::Error>

Attempts to convert i8\nto NonZero<i8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroI8"],["
1.46.0 · Source§

impl TryFrom<isize> for NonZero<isize>

Source§

fn try_from(value: isize) -> Result<Self, Self::Error>

Attempts to convert isize\nto NonZero<isize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroIsize"],["
1.46.0 · Source§

impl TryFrom<u128> for NonZero<u128>

Source§

fn try_from(value: u128) -> Result<Self, Self::Error>

Attempts to convert u128\nto NonZero<u128>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroU128"],["
1.46.0 · Source§

impl TryFrom<u16> for NonZero<u16>

Source§

fn try_from(value: u16) -> Result<Self, Self::Error>

Attempts to convert u16\nto NonZero<u16>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroU16"],["
1.46.0 · Source§

impl TryFrom<u32> for NonZero<u32>

Source§

fn try_from(value: u32) -> Result<Self, Self::Error>

Attempts to convert u32\nto NonZero<u32>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroU32"],["
1.46.0 · Source§

impl TryFrom<u64> for NonZero<u64>

Source§

fn try_from(value: u64) -> Result<Self, Self::Error>

Attempts to convert u64\nto NonZero<u64>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroU64"],["
1.46.0 · Source§

impl TryFrom<u8> for NonZero<u8>

Source§

fn try_from(value: u8) -> Result<Self, Self::Error>

Attempts to convert u8\nto NonZero<u8>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroU8"],["
1.46.0 · Source§

impl TryFrom<usize> for NonZero<usize>

Source§

fn try_from(value: usize) -> Result<Self, Self::Error>

Attempts to convert usize\nto NonZero<usize>.

\n
Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
","TryFrom","core::num::nonzero::NonZeroUsize"],["
1.84.0 · Source§

impl<T> UpperExp for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","UpperExp","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> UpperHex for NonZero<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
","UpperHex","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Copy for NonZero<T>
where\n T: ZeroablePrimitive,

","Copy","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Eq for NonZero<T>
where\n T: ZeroablePrimitive + Eq,

","Eq","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Freeze for NonZero<T>

","Freeze","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> RefUnwindSafe for NonZero<T>

","RefUnwindSafe","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Send for NonZero<T>
where\n T: ZeroablePrimitive + Send,

","Send","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
Source§

impl<T> StructuralPartialEq for NonZero<T>

","StructuralPartialEq","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Sync for NonZero<T>
where\n T: ZeroablePrimitive + Sync,

","Sync","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> Unpin for NonZero<T>
where\n T: ZeroablePrimitive + Unpin,

","Unpin","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
1.28.0 · Source§

impl<T> UnwindSafe for NonZero<T>

","UnwindSafe","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"],["
Source§

impl<T> UseCloned for NonZero<T>
where\n T: ZeroablePrimitive,

","UseCloned","core::num::nonzero::NonZeroU8","core::num::nonzero::NonZeroU16","core::num::nonzero::NonZeroU32","core::num::nonzero::NonZeroU64","core::num::nonzero::NonZeroU128","core::num::nonzero::NonZeroUsize","core::num::nonzero::NonZeroI8","core::num::nonzero::NonZeroI16","core::num::nonzero::NonZeroI32","core::num::nonzero::NonZeroI64","core::num::nonzero::NonZeroI128","core::num::nonzero::NonZeroIsize"]]]]); if (window.register_type_impls) { window.register_type_impls(type_impls); } else { window.pending_type_impls = type_impls; } })() //{"start":55,"fragment_lengths":[1290653]}