Struct std::num::NonZero

source ·
pub struct NonZero<T>(/* private fields */)
where
    T: ZeroablePrimitive;
🔬This is a nightly-only experimental API. (generic_nonzero #120257)
Expand description

A value that is known not to equal zero.

This enables some memory layout optimization. For example, Option<NonZero<u32>> is the same size as u32:

#![feature(generic_nonzero)]
use core::mem::size_of;

assert_eq!(size_of::<Option<core::num::NonZero<u32>>>(), size_of::<u32>());
Run

Implementations§

source§

impl NonZero<u8>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: u8) -> NonZero<u8>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: u8) -> Option<NonZero<u8>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut u8) -> &mut NonZero<u8>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut u8) -> Option<&mut NonZero<u8>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> u8

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 8u32

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

This value is equal to u8::BITS.

§Examples

assert_eq!(NonZeroU8::BITS, u8::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroU8::new(u8::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroU8::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroU8::new(0b100_0000)?;
let b = NonZeroU8::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<u8> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroU8::MIN.get(), 1u8);
Run
1.70.0 · source

pub const MAX: NonZero<u8> = _

The largest value that can be represented by this non-zero integer type, equal to u8::MAX.

§Examples
assert_eq!(NonZeroU8::MAX.get(), u8::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: u8) -> Option<NonZero<u8>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroU8::new(1)?;
let two = NonZeroU8::new(2)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: u8) -> NonZero<u8>

Adds an unsigned integer to a non-zero value. Return NonZeroU8::MAX on overflow.

§Examples
let one = NonZeroU8::new(1)?;
let two = NonZeroU8::new(2)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: u8) -> NonZero<u8>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > u8::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroU8::new(1)?;
let two = NonZeroU8::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<u8>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroU8::new(2)?;
let three = NonZeroU8::new(3)?;
let four = NonZeroU8::new(4)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as u8::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU8::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroU8::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroU8::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as u8::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU8::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroU8::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroU8::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<u8>) -> NonZero<u8>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroU8::new(1)?;
let two = NonZeroU8::new(2)?;
let four = NonZeroU8::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroU8::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroU8::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroU8::new(2)?;
let four = NonZeroU8::new(4)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<u8>) -> NonZero<u8>

Multiplies two non-zero integers together. Return NonZeroU8::MAX on overflow.

§Examples
let two = NonZeroU8::new(2)?;
let four = NonZeroU8::new(4)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<u8>) -> NonZero<u8>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > u8::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroU8::new(2)?;
let four = NonZeroU8::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroU8::new(3)?;
let twenty_seven = NonZeroU8::new(27)?;
let half_max = NonZeroU8::new(u8::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<u8>

Raise non-zero value to an integer power. Return NonZeroU8::MAX on overflow.

§Examples
let three = NonZeroU8::new(3)?;
let twenty_seven = NonZeroU8::new(27)?;
let max = NonZeroU8::new(u8::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<u16>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: u16) -> NonZero<u16>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: u16) -> Option<NonZero<u16>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut u16) -> &mut NonZero<u16>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut u16) -> Option<&mut NonZero<u16>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> u16

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 16u32

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

This value is equal to u16::BITS.

§Examples

assert_eq!(NonZeroU16::BITS, u16::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroU16::new(u16::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroU16::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroU16::new(0b100_0000)?;
let b = NonZeroU16::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<u16> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroU16::MIN.get(), 1u16);
Run
1.70.0 · source

pub const MAX: NonZero<u16> = _

The largest value that can be represented by this non-zero integer type, equal to u16::MAX.

§Examples
assert_eq!(NonZeroU16::MAX.get(), u16::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: u16) -> Option<NonZero<u16>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroU16::new(1)?;
let two = NonZeroU16::new(2)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: u16) -> NonZero<u16>

Adds an unsigned integer to a non-zero value. Return NonZeroU16::MAX on overflow.

§Examples
let one = NonZeroU16::new(1)?;
let two = NonZeroU16::new(2)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: u16) -> NonZero<u16>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > u16::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroU16::new(1)?;
let two = NonZeroU16::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<u16>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroU16::new(2)?;
let three = NonZeroU16::new(3)?;
let four = NonZeroU16::new(4)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as u16::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU16::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroU16::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroU16::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as u16::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU16::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroU16::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroU16::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<u16>) -> NonZero<u16>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroU16::new(1)?;
let two = NonZeroU16::new(2)?;
let four = NonZeroU16::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroU16::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroU16::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroU16::new(2)?;
let four = NonZeroU16::new(4)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<u16>) -> NonZero<u16>

Multiplies two non-zero integers together. Return NonZeroU16::MAX on overflow.

§Examples
let two = NonZeroU16::new(2)?;
let four = NonZeroU16::new(4)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<u16>) -> NonZero<u16>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > u16::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroU16::new(2)?;
let four = NonZeroU16::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroU16::new(3)?;
let twenty_seven = NonZeroU16::new(27)?;
let half_max = NonZeroU16::new(u16::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<u16>

Raise non-zero value to an integer power. Return NonZeroU16::MAX on overflow.

§Examples
let three = NonZeroU16::new(3)?;
let twenty_seven = NonZeroU16::new(27)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<u32>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: u32) -> NonZero<u32>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: u32) -> Option<NonZero<u32>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut u32) -> &mut NonZero<u32>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut u32) -> Option<&mut NonZero<u32>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> u32

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 32u32

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

This value is equal to u32::BITS.

§Examples

assert_eq!(NonZeroU32::BITS, u32::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroU32::new(u32::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroU32::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroU32::new(0b100_0000)?;
let b = NonZeroU32::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<u32> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroU32::MIN.get(), 1u32);
Run
1.70.0 · source

pub const MAX: NonZero<u32> = _

The largest value that can be represented by this non-zero integer type, equal to u32::MAX.

§Examples
assert_eq!(NonZeroU32::MAX.get(), u32::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: u32) -> Option<NonZero<u32>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroU32::new(1)?;
let two = NonZeroU32::new(2)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: u32) -> NonZero<u32>

Adds an unsigned integer to a non-zero value. Return NonZeroU32::MAX on overflow.

§Examples
let one = NonZeroU32::new(1)?;
let two = NonZeroU32::new(2)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: u32) -> NonZero<u32>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > u32::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroU32::new(1)?;
let two = NonZeroU32::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<u32>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroU32::new(2)?;
let three = NonZeroU32::new(3)?;
let four = NonZeroU32::new(4)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as u32::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU32::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroU32::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroU32::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as u32::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU32::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroU32::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroU32::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<u32>) -> NonZero<u32>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroU32::new(1)?;
let two = NonZeroU32::new(2)?;
let four = NonZeroU32::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroU32::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroU32::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroU32::new(2)?;
let four = NonZeroU32::new(4)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<u32>) -> NonZero<u32>

Multiplies two non-zero integers together. Return NonZeroU32::MAX on overflow.

§Examples
let two = NonZeroU32::new(2)?;
let four = NonZeroU32::new(4)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<u32>) -> NonZero<u32>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > u32::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroU32::new(2)?;
let four = NonZeroU32::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroU32::new(3)?;
let twenty_seven = NonZeroU32::new(27)?;
let half_max = NonZeroU32::new(u32::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

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

Raise non-zero value to an integer power. Return NonZeroU32::MAX on overflow.

§Examples
let three = NonZeroU32::new(3)?;
let twenty_seven = NonZeroU32::new(27)?;
let max = NonZeroU32::new(u32::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<u64>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: u64) -> NonZero<u64>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: u64) -> Option<NonZero<u64>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut u64) -> &mut NonZero<u64>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut u64) -> Option<&mut NonZero<u64>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> u64

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 64u32

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

This value is equal to u64::BITS.

§Examples

assert_eq!(NonZeroU64::BITS, u64::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroU64::new(u64::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroU64::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroU64::new(0b100_0000)?;
let b = NonZeroU64::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<u64> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroU64::MIN.get(), 1u64);
Run
1.70.0 · source

pub const MAX: NonZero<u64> = _

The largest value that can be represented by this non-zero integer type, equal to u64::MAX.

§Examples
assert_eq!(NonZeroU64::MAX.get(), u64::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: u64) -> Option<NonZero<u64>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroU64::new(1)?;
let two = NonZeroU64::new(2)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: u64) -> NonZero<u64>

Adds an unsigned integer to a non-zero value. Return NonZeroU64::MAX on overflow.

§Examples
let one = NonZeroU64::new(1)?;
let two = NonZeroU64::new(2)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: u64) -> NonZero<u64>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > u64::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroU64::new(1)?;
let two = NonZeroU64::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<u64>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroU64::new(2)?;
let three = NonZeroU64::new(3)?;
let four = NonZeroU64::new(4)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as u64::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU64::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroU64::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroU64::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as u64::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU64::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroU64::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroU64::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<u64>) -> NonZero<u64>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroU64::new(1)?;
let two = NonZeroU64::new(2)?;
let four = NonZeroU64::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroU64::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroU64::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroU64::new(2)?;
let four = NonZeroU64::new(4)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<u64>) -> NonZero<u64>

Multiplies two non-zero integers together. Return NonZeroU64::MAX on overflow.

§Examples
let two = NonZeroU64::new(2)?;
let four = NonZeroU64::new(4)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<u64>) -> NonZero<u64>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > u64::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroU64::new(2)?;
let four = NonZeroU64::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroU64::new(3)?;
let twenty_seven = NonZeroU64::new(27)?;
let half_max = NonZeroU64::new(u64::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<u64>

Raise non-zero value to an integer power. Return NonZeroU64::MAX on overflow.

§Examples
let three = NonZeroU64::new(3)?;
let twenty_seven = NonZeroU64::new(27)?;
let max = NonZeroU64::new(u64::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<u128>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: u128) -> NonZero<u128>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: u128) -> Option<NonZero<u128>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut u128) -> &mut NonZero<u128>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut u128) -> Option<&mut NonZero<u128>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> u128

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 128u32

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

This value is equal to u128::BITS.

§Examples

assert_eq!(NonZeroU128::BITS, u128::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroU128::new(u128::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroU128::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroU128::new(0b100_0000)?;
let b = NonZeroU128::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<u128> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroU128::MIN.get(), 1u128);
Run
1.70.0 · source

pub const MAX: NonZero<u128> = _

The largest value that can be represented by this non-zero integer type, equal to u128::MAX.

§Examples
assert_eq!(NonZeroU128::MAX.get(), u128::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: u128) -> Option<NonZero<u128>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroU128::new(1)?;
let two = NonZeroU128::new(2)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: u128) -> NonZero<u128>

Adds an unsigned integer to a non-zero value. Return NonZeroU128::MAX on overflow.

§Examples
let one = NonZeroU128::new(1)?;
let two = NonZeroU128::new(2)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: u128) -> NonZero<u128>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > u128::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroU128::new(1)?;
let two = NonZeroU128::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<u128>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroU128::new(2)?;
let three = NonZeroU128::new(3)?;
let four = NonZeroU128::new(4)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as u128::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU128::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroU128::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroU128::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as u128::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroU128::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroU128::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroU128::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<u128>) -> NonZero<u128>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroU128::new(1)?;
let two = NonZeroU128::new(2)?;
let four = NonZeroU128::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroU128::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroU128::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroU128::new(2)?;
let four = NonZeroU128::new(4)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<u128>) -> NonZero<u128>

Multiplies two non-zero integers together. Return NonZeroU128::MAX on overflow.

§Examples
let two = NonZeroU128::new(2)?;
let four = NonZeroU128::new(4)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<u128>) -> NonZero<u128>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > u128::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroU128::new(2)?;
let four = NonZeroU128::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroU128::new(3)?;
let twenty_seven = NonZeroU128::new(27)?;
let half_max = NonZeroU128::new(u128::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<u128>

Raise non-zero value to an integer power. Return NonZeroU128::MAX on overflow.

§Examples
let three = NonZeroU128::new(3)?;
let twenty_seven = NonZeroU128::new(27)?;
let max = NonZeroU128::new(u128::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<usize>

1.28.0 (const: 1.28.0) · source

pub const unsafe fn new_unchecked(n: usize) -> NonZero<usize>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.28.0 (const: 1.47.0) · source

pub const fn new(n: usize) -> Option<NonZero<usize>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut usize) -> &mut NonZero<usize>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut usize) -> Option<&mut NonZero<usize>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> usize

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 64u32

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

This value is equal to usize::BITS.

§Examples

assert_eq!(NonZeroUsize::BITS, usize::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroUsize::new(usize::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroUsize::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroUsize::new(0b100_0000)?;
let b = NonZeroUsize::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<usize> = _

The smallest value that can be represented by this non-zero integer type, 1.

§Examples
assert_eq!(NonZeroUsize::MIN.get(), 1usize);
Run
1.70.0 · source

pub const MAX: NonZero<usize> = _

The largest value that can be represented by this non-zero integer type, equal to usize::MAX.

§Examples
assert_eq!(NonZeroUsize::MAX.get(), usize::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_add(self, other: usize) -> Option<NonZero<usize>>

Adds an unsigned integer to a non-zero value. Checks for overflow and returns None on overflow. As a consequence, the result cannot wrap to zero.

§Examples
let one = NonZeroUsize::new(1)?;
let two = NonZeroUsize::new(2)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_add(self, other: usize) -> NonZero<usize>

Adds an unsigned integer to a non-zero value. Return NonZeroUsize::MAX on overflow.

§Examples
let one = NonZeroUsize::new(1)?;
let two = NonZeroUsize::new(2)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(two, one.saturating_add(1));
assert_eq!(max, max.saturating_add(1));
Run
source

pub const unsafe fn unchecked_add(self, other: usize) -> NonZero<usize>

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

Adds an unsigned integer to a non-zero value, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self + rhs > usize::MAX.

§Examples
#![feature(nonzero_ops)]

let one = NonZeroUsize::new(1)?;
let two = NonZeroUsize::new(2)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_next_power_of_two(self) -> Option<NonZero<usize>>

Returns the smallest power of two greater than or equal to n. Checks for overflow and returns None if the next power of two is greater than the type’s maximum value. As a consequence, the result cannot wrap to zero.

§Examples
let two = NonZeroUsize::new(2)?;
let three = NonZeroUsize::new(3)?;
let four = NonZeroUsize::new(4)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(Some(two), two.checked_next_power_of_two() );
assert_eq!(Some(four), three.checked_next_power_of_two() );
assert_eq!(None, max.checked_next_power_of_two() );
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog2(self) -> u32

Returns the base 2 logarithm of the number, rounded down.

This is the same operation as usize::ilog2, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroUsize::new(7).unwrap().ilog2(), 2);
assert_eq!(NonZeroUsize::new(8).unwrap().ilog2(), 3);
assert_eq!(NonZeroUsize::new(9).unwrap().ilog2(), 3);
Run
1.67.0 (const: 1.67.0) · source

pub const fn ilog10(self) -> u32

Returns the base 10 logarithm of the number, rounded down.

This is the same operation as usize::ilog10, except that it has no failure cases to worry about since this value can never be zero.

§Examples
assert_eq!(NonZeroUsize::new(99).unwrap().ilog10(), 1);
assert_eq!(NonZeroUsize::new(100).unwrap().ilog10(), 2);
assert_eq!(NonZeroUsize::new(101).unwrap().ilog10(), 2);
Run
const: unstable · source

pub fn midpoint(self, rhs: NonZero<usize>) -> NonZero<usize>

🔬This is a nightly-only experimental API. (num_midpoint #110840)

Calculates the middle point of self and rhs.

midpoint(a, b) is (a + b) >> 1 as if it were performed in a sufficiently-large signed integral type. This implies that the result is always rounded towards negative infinity and that no overflow will ever occur.

§Examples
#![feature(num_midpoint)]

let one = NonZeroUsize::new(1)?;
let two = NonZeroUsize::new(2)?;
let four = NonZeroUsize::new(4)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
Run
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.

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

§Examples

Basic usage:

let eight = std::num::NonZeroUsize::new(8).unwrap();
assert!(eight.is_power_of_two());
let ten = std::num::NonZeroUsize::new(10).unwrap();
assert!(!ten.is_power_of_two());
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroUsize::new(2)?;
let four = NonZeroUsize::new(4)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<usize>) -> NonZero<usize>

Multiplies two non-zero integers together. Return NonZeroUsize::MAX on overflow.

§Examples
let two = NonZeroUsize::new(2)?;
let four = NonZeroUsize::new(4)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<usize>) -> NonZero<usize>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > usize::MAX.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroUsize::new(2)?;
let four = NonZeroUsize::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroUsize::new(3)?;
let twenty_seven = NonZeroUsize::new(27)?;
let half_max = NonZeroUsize::new(usize::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<usize>

Raise non-zero value to an integer power. Return NonZeroUsize::MAX on overflow.

§Examples
let three = NonZeroUsize::new(3)?;
let twenty_seven = NonZeroUsize::new(27)?;
let max = NonZeroUsize::new(usize::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<i8>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: i8) -> NonZero<i8>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: i8) -> Option<NonZero<i8>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut i8) -> &mut NonZero<i8>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut i8) -> Option<&mut NonZero<i8>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> i8

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 8u32

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

This value is equal to i8::BITS.

§Examples

assert_eq!(NonZeroI8::BITS, i8::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroI8::new(-1i8).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroI8::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroI8::new(0b100_0000)?;
let b = NonZeroI8::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<i8> = _

The smallest value that can be represented by this non-zero integer type, equal to i8::MIN.

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

§Examples
assert_eq!(NonZeroI8::MIN.get(), i8::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<i8> = _

The largest value that can be represented by this non-zero integer type, equal to i8::MAX.

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

§Examples
assert_eq!(NonZeroI8::MAX.get(), i8::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<i8>

Computes the absolute value of self. See i8::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<i8>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroI8::MIN. The result cannot be zero.

§Example
let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<i8>, bool)

Computes the absolute value of self, with overflow information, see i8::overflowing_abs.

§Example
let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<i8>

Saturating absolute value, see i8::saturating_abs.

§Example
let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;
let min = NonZeroI8::new(i8::MIN)?;
let min_plus = NonZeroI8::new(i8::MIN + 1)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<i8>

Wrapping absolute value, see i8::wrapping_abs.

§Example
let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroU8::new(1)?;
let i_pos = NonZeroI8::new(1)?;
let i_neg = NonZeroI8::new(-1)?;
let i_min = NonZeroI8::new(i8::MIN)?;
let u_max = NonZeroU8::new(u8::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<i8>>

Checked negation. Computes -self, returning None if self == NonZeroI8::MIN.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<i8>, bool)

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

See i8::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<i8>

Saturating negation. Computes -self, returning NonZeroI8::MAX if self == NonZeroI8::MIN instead of overflowing.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;
let min = NonZeroI8::new(i8::MIN)?;
let min_plus_one = NonZeroI8::new(i8::MIN + 1)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<i8>

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

See i8::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI8::new(5)?;
let neg_five = NonZeroI8::new(-5)?;
let min = NonZeroI8::new(i8::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroI8::new(2)?;
let four = NonZeroI8::new(4)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<i8>) -> NonZero<i8>

Multiplies two non-zero integers together. Return NonZeroI8::MAX on overflow.

§Examples
let two = NonZeroI8::new(2)?;
let four = NonZeroI8::new(4)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<i8>) -> NonZero<i8>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > i8::MAX, or self * rhs < i8::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroI8::new(2)?;
let four = NonZeroI8::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroI8::new(3)?;
let twenty_seven = NonZeroI8::new(27)?;
let half_max = NonZeroI8::new(i8::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<i8>

Raise non-zero value to an integer power. Return NonZeroI8::MIN or NonZeroI8::MAX on overflow.

§Examples
let three = NonZeroI8::new(3)?;
let twenty_seven = NonZeroI8::new(27)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<i16>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: i16) -> NonZero<i16>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: i16) -> Option<NonZero<i16>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut i16) -> &mut NonZero<i16>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut i16) -> Option<&mut NonZero<i16>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> i16

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 16u32

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

This value is equal to i16::BITS.

§Examples

assert_eq!(NonZeroI16::BITS, i16::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroI16::new(-1i16).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroI16::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroI16::new(0b100_0000)?;
let b = NonZeroI16::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<i16> = _

The smallest value that can be represented by this non-zero integer type, equal to i16::MIN.

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

§Examples
assert_eq!(NonZeroI16::MIN.get(), i16::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<i16> = _

The largest value that can be represented by this non-zero integer type, equal to i16::MAX.

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

§Examples
assert_eq!(NonZeroI16::MAX.get(), i16::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<i16>

Computes the absolute value of self. See i16::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroI16::new(1)?;
let neg = NonZeroI16::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<i16>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroI16::MIN. The result cannot be zero.

§Example
let pos = NonZeroI16::new(1)?;
let neg = NonZeroI16::new(-1)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<i16>, bool)

Computes the absolute value of self, with overflow information, see i16::overflowing_abs.

§Example
let pos = NonZeroI16::new(1)?;
let neg = NonZeroI16::new(-1)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<i16>

Saturating absolute value, see i16::saturating_abs.

§Example
let pos = NonZeroI16::new(1)?;
let neg = NonZeroI16::new(-1)?;
let min = NonZeroI16::new(i16::MIN)?;
let min_plus = NonZeroI16::new(i16::MIN + 1)?;
let max = NonZeroI16::new(i16::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<i16>

Wrapping absolute value, see i16::wrapping_abs.

§Example
let pos = NonZeroI16::new(1)?;
let neg = NonZeroI16::new(-1)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroU16::new(1)?;
let i_pos = NonZeroI16::new(1)?;
let i_neg = NonZeroI16::new(-1)?;
let i_min = NonZeroI16::new(i16::MIN)?;
let u_max = NonZeroU16::new(u16::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<i16>>

Checked negation. Computes -self, returning None if self == NonZeroI16::MIN.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<i16>, bool)

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

See i16::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<i16>

Saturating negation. Computes -self, returning NonZeroI16::MAX if self == NonZeroI16::MIN instead of overflowing.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;
let min = NonZeroI16::new(i16::MIN)?;
let min_plus_one = NonZeroI16::new(i16::MIN + 1)?;
let max = NonZeroI16::new(i16::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<i16>

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

See i16::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI16::new(5)?;
let neg_five = NonZeroI16::new(-5)?;
let min = NonZeroI16::new(i16::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroI16::new(2)?;
let four = NonZeroI16::new(4)?;
let max = NonZeroI16::new(i16::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<i16>) -> NonZero<i16>

Multiplies two non-zero integers together. Return NonZeroI16::MAX on overflow.

§Examples
let two = NonZeroI16::new(2)?;
let four = NonZeroI16::new(4)?;
let max = NonZeroI16::new(i16::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<i16>) -> NonZero<i16>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > i16::MAX, or self * rhs < i16::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroI16::new(2)?;
let four = NonZeroI16::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroI16::new(3)?;
let twenty_seven = NonZeroI16::new(27)?;
let half_max = NonZeroI16::new(i16::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<i16>

Raise non-zero value to an integer power. Return NonZeroI16::MIN or NonZeroI16::MAX on overflow.

§Examples
let three = NonZeroI16::new(3)?;
let twenty_seven = NonZeroI16::new(27)?;
let max = NonZeroI16::new(i16::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<i32>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: i32) -> NonZero<i32>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: i32) -> Option<NonZero<i32>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut i32) -> &mut NonZero<i32>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut i32) -> Option<&mut NonZero<i32>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> i32

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 32u32

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

This value is equal to i32::BITS.

§Examples

assert_eq!(NonZeroI32::BITS, i32::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroI32::new(-1i32).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroI32::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroI32::new(0b100_0000)?;
let b = NonZeroI32::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<i32> = _

The smallest value that can be represented by this non-zero integer type, equal to i32::MIN.

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

§Examples
assert_eq!(NonZeroI32::MIN.get(), i32::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<i32> = _

The largest value that can be represented by this non-zero integer type, equal to i32::MAX.

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

§Examples
assert_eq!(NonZeroI32::MAX.get(), i32::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<i32>

Computes the absolute value of self. See i32::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroI32::new(1)?;
let neg = NonZeroI32::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<i32>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroI32::MIN. The result cannot be zero.

§Example
let pos = NonZeroI32::new(1)?;
let neg = NonZeroI32::new(-1)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<i32>, bool)

Computes the absolute value of self, with overflow information, see i32::overflowing_abs.

§Example
let pos = NonZeroI32::new(1)?;
let neg = NonZeroI32::new(-1)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<i32>

Saturating absolute value, see i32::saturating_abs.

§Example
let pos = NonZeroI32::new(1)?;
let neg = NonZeroI32::new(-1)?;
let min = NonZeroI32::new(i32::MIN)?;
let min_plus = NonZeroI32::new(i32::MIN + 1)?;
let max = NonZeroI32::new(i32::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<i32>

Wrapping absolute value, see i32::wrapping_abs.

§Example
let pos = NonZeroI32::new(1)?;
let neg = NonZeroI32::new(-1)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroU32::new(1)?;
let i_pos = NonZeroI32::new(1)?;
let i_neg = NonZeroI32::new(-1)?;
let i_min = NonZeroI32::new(i32::MIN)?;
let u_max = NonZeroU32::new(u32::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<i32>>

Checked negation. Computes -self, returning None if self == NonZeroI32::MIN.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<i32>, bool)

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

See i32::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<i32>

Saturating negation. Computes -self, returning NonZeroI32::MAX if self == NonZeroI32::MIN instead of overflowing.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;
let min = NonZeroI32::new(i32::MIN)?;
let min_plus_one = NonZeroI32::new(i32::MIN + 1)?;
let max = NonZeroI32::new(i32::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<i32>

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

See i32::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI32::new(5)?;
let neg_five = NonZeroI32::new(-5)?;
let min = NonZeroI32::new(i32::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroI32::new(2)?;
let four = NonZeroI32::new(4)?;
let max = NonZeroI32::new(i32::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<i32>) -> NonZero<i32>

Multiplies two non-zero integers together. Return NonZeroI32::MAX on overflow.

§Examples
let two = NonZeroI32::new(2)?;
let four = NonZeroI32::new(4)?;
let max = NonZeroI32::new(i32::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<i32>) -> NonZero<i32>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > i32::MAX, or self * rhs < i32::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroI32::new(2)?;
let four = NonZeroI32::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroI32::new(3)?;
let twenty_seven = NonZeroI32::new(27)?;
let half_max = NonZeroI32::new(i32::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<i32>

Raise non-zero value to an integer power. Return NonZeroI32::MIN or NonZeroI32::MAX on overflow.

§Examples
let three = NonZeroI32::new(3)?;
let twenty_seven = NonZeroI32::new(27)?;
let max = NonZeroI32::new(i32::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<i64>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: i64) -> NonZero<i64>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: i64) -> Option<NonZero<i64>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut i64) -> &mut NonZero<i64>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut i64) -> Option<&mut NonZero<i64>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> i64

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 64u32

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

This value is equal to i64::BITS.

§Examples

assert_eq!(NonZeroI64::BITS, i64::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroI64::new(-1i64).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroI64::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroI64::new(0b100_0000)?;
let b = NonZeroI64::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<i64> = _

The smallest value that can be represented by this non-zero integer type, equal to i64::MIN.

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

§Examples
assert_eq!(NonZeroI64::MIN.get(), i64::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<i64> = _

The largest value that can be represented by this non-zero integer type, equal to i64::MAX.

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

§Examples
assert_eq!(NonZeroI64::MAX.get(), i64::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<i64>

Computes the absolute value of self. See i64::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroI64::new(1)?;
let neg = NonZeroI64::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<i64>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroI64::MIN. The result cannot be zero.

§Example
let pos = NonZeroI64::new(1)?;
let neg = NonZeroI64::new(-1)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<i64>, bool)

Computes the absolute value of self, with overflow information, see i64::overflowing_abs.

§Example
let pos = NonZeroI64::new(1)?;
let neg = NonZeroI64::new(-1)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<i64>

Saturating absolute value, see i64::saturating_abs.

§Example
let pos = NonZeroI64::new(1)?;
let neg = NonZeroI64::new(-1)?;
let min = NonZeroI64::new(i64::MIN)?;
let min_plus = NonZeroI64::new(i64::MIN + 1)?;
let max = NonZeroI64::new(i64::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<i64>

Wrapping absolute value, see i64::wrapping_abs.

§Example
let pos = NonZeroI64::new(1)?;
let neg = NonZeroI64::new(-1)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroU64::new(1)?;
let i_pos = NonZeroI64::new(1)?;
let i_neg = NonZeroI64::new(-1)?;
let i_min = NonZeroI64::new(i64::MIN)?;
let u_max = NonZeroU64::new(u64::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<i64>>

Checked negation. Computes -self, returning None if self == NonZeroI64::MIN.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<i64>, bool)

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

See i64::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<i64>

Saturating negation. Computes -self, returning NonZeroI64::MAX if self == NonZeroI64::MIN instead of overflowing.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;
let min = NonZeroI64::new(i64::MIN)?;
let min_plus_one = NonZeroI64::new(i64::MIN + 1)?;
let max = NonZeroI64::new(i64::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<i64>

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

See i64::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI64::new(5)?;
let neg_five = NonZeroI64::new(-5)?;
let min = NonZeroI64::new(i64::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroI64::new(2)?;
let four = NonZeroI64::new(4)?;
let max = NonZeroI64::new(i64::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<i64>) -> NonZero<i64>

Multiplies two non-zero integers together. Return NonZeroI64::MAX on overflow.

§Examples
let two = NonZeroI64::new(2)?;
let four = NonZeroI64::new(4)?;
let max = NonZeroI64::new(i64::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<i64>) -> NonZero<i64>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > i64::MAX, or self * rhs < i64::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroI64::new(2)?;
let four = NonZeroI64::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroI64::new(3)?;
let twenty_seven = NonZeroI64::new(27)?;
let half_max = NonZeroI64::new(i64::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<i64>

Raise non-zero value to an integer power. Return NonZeroI64::MIN or NonZeroI64::MAX on overflow.

§Examples
let three = NonZeroI64::new(3)?;
let twenty_seven = NonZeroI64::new(27)?;
let max = NonZeroI64::new(i64::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<i128>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: i128) -> NonZero<i128>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: i128) -> Option<NonZero<i128>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut i128) -> &mut NonZero<i128>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut i128) -> Option<&mut NonZero<i128>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> i128

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 128u32

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

This value is equal to i128::BITS.

§Examples

assert_eq!(NonZeroI128::BITS, i128::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroI128::new(-1i128).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroI128::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroI128::new(0b100_0000)?;
let b = NonZeroI128::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<i128> = _

The smallest value that can be represented by this non-zero integer type, equal to i128::MIN.

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

§Examples
assert_eq!(NonZeroI128::MIN.get(), i128::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<i128> = _

The largest value that can be represented by this non-zero integer type, equal to i128::MAX.

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

§Examples
assert_eq!(NonZeroI128::MAX.get(), i128::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<i128>

Computes the absolute value of self. See i128::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroI128::new(1)?;
let neg = NonZeroI128::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<i128>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroI128::MIN. The result cannot be zero.

§Example
let pos = NonZeroI128::new(1)?;
let neg = NonZeroI128::new(-1)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<i128>, bool)

Computes the absolute value of self, with overflow information, see i128::overflowing_abs.

§Example
let pos = NonZeroI128::new(1)?;
let neg = NonZeroI128::new(-1)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<i128>

Saturating absolute value, see i128::saturating_abs.

§Example
let pos = NonZeroI128::new(1)?;
let neg = NonZeroI128::new(-1)?;
let min = NonZeroI128::new(i128::MIN)?;
let min_plus = NonZeroI128::new(i128::MIN + 1)?;
let max = NonZeroI128::new(i128::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<i128>

Wrapping absolute value, see i128::wrapping_abs.

§Example
let pos = NonZeroI128::new(1)?;
let neg = NonZeroI128::new(-1)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroU128::new(1)?;
let i_pos = NonZeroI128::new(1)?;
let i_neg = NonZeroI128::new(-1)?;
let i_min = NonZeroI128::new(i128::MIN)?;
let u_max = NonZeroU128::new(u128::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<i128>>

Checked negation. Computes -self, returning None if self == NonZeroI128::MIN.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<i128>, bool)

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

See i128::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<i128>

Saturating negation. Computes -self, returning NonZeroI128::MAX if self == NonZeroI128::MIN instead of overflowing.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;
let min = NonZeroI128::new(i128::MIN)?;
let min_plus_one = NonZeroI128::new(i128::MIN + 1)?;
let max = NonZeroI128::new(i128::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<i128>

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

See i128::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroI128::new(5)?;
let neg_five = NonZeroI128::new(-5)?;
let min = NonZeroI128::new(i128::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroI128::new(2)?;
let four = NonZeroI128::new(4)?;
let max = NonZeroI128::new(i128::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<i128>) -> NonZero<i128>

Multiplies two non-zero integers together. Return NonZeroI128::MAX on overflow.

§Examples
let two = NonZeroI128::new(2)?;
let four = NonZeroI128::new(4)?;
let max = NonZeroI128::new(i128::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<i128>) -> NonZero<i128>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > i128::MAX, or self * rhs < i128::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroI128::new(2)?;
let four = NonZeroI128::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroI128::new(3)?;
let twenty_seven = NonZeroI128::new(27)?;
let half_max = NonZeroI128::new(i128::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<i128>

Raise non-zero value to an integer power. Return NonZeroI128::MIN or NonZeroI128::MAX on overflow.

§Examples
let three = NonZeroI128::new(3)?;
let twenty_seven = NonZeroI128::new(27)?;
let max = NonZeroI128::new(i128::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run
source§

impl NonZero<isize>

1.34.0 (const: 1.34.0) · source

pub const unsafe fn new_unchecked(n: isize) -> NonZero<isize>

Creates a non-zero without checking whether the value is non-zero. This results in undefined behaviour if the value is zero.

§Safety

The value must not be zero.

1.34.0 (const: 1.47.0) · source

pub const fn new(n: isize) -> Option<NonZero<isize>>

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

source

pub unsafe fn from_mut_unchecked(n: &mut isize) -> &mut NonZero<isize>

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

Converts a primitive mutable reference to a non-zero mutable reference without checking whether the referenced value is non-zero. This results in undefined behavior if *n is zero.

§Safety

The referenced value must not be currently zero.

source

pub fn from_mut(n: &mut isize) -> Option<&mut NonZero<isize>>

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

Converts a primitive mutable reference to a non-zero mutable reference if the referenced integer is not zero.

1.34.0 (const: 1.34.0) · source

pub const fn get(self) -> isize

Returns the value as a primitive type.

1.67.0 · source

pub const BITS: u32 = 64u32

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

This value is equal to isize::BITS.

§Examples

assert_eq!(NonZeroIsize::BITS, isize::BITS);
Run
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.

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

§Examples

Basic usage:

let n = std::num::NonZeroIsize::new(-1isize).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run
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 of self.

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

§Examples

Basic usage:

let n = std::num::NonZeroIsize::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run
const: unstable · source

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

🔬This is a nightly-only experimental API. (non_zero_count_ones #120287)

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let one = num::NonZeroU32::new(1)?;
let three = num::NonZeroU32::new(3)?;
let a = NonZeroIsize::new(0b100_0000)?;
let b = NonZeroIsize::new(0b100_0011)?;

assert_eq!(a.count_ones(), one);
assert_eq!(b.count_ones(), three);
Run
1.70.0 · source

pub const MIN: NonZero<isize> = _

The smallest value that can be represented by this non-zero integer type, equal to isize::MIN.

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

§Examples
assert_eq!(NonZeroIsize::MIN.get(), isize::MIN);
Run
1.70.0 · source

pub const MAX: NonZero<isize> = _

The largest value that can be represented by this non-zero integer type, equal to isize::MAX.

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

§Examples
assert_eq!(NonZeroIsize::MAX.get(), isize::MAX);
Run
1.64.0 (const: 1.64.0) · source

pub const fn abs(self) -> NonZero<isize>

Computes the absolute value of self. See isize::abs for documentation on overflow behaviour.

§Example
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn checked_abs(self) -> Option<NonZero<isize>>

Checked absolute value. Checks for overflow and returns None if self == NonZeroIsize::MIN. The result cannot be zero.

§Example
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn overflowing_abs(self) -> (NonZero<isize>, bool)

Computes the absolute value of self, with overflow information, see isize::overflowing_abs.

§Example
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_abs(self) -> NonZero<isize>

Saturating absolute value, see isize::saturating_abs.

§Example
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;
let min = NonZeroIsize::new(isize::MIN)?;
let min_plus = NonZeroIsize::new(isize::MIN + 1)?;
let max = NonZeroIsize::new(isize::MAX)?;

assert_eq!(pos, pos.saturating_abs());
assert_eq!(pos, neg.saturating_abs());
assert_eq!(max, min.saturating_abs());
assert_eq!(max, min_plus.saturating_abs());
Run
1.64.0 (const: 1.64.0) · source

pub const fn wrapping_abs(self) -> NonZero<isize>

Wrapping absolute value, see isize::wrapping_abs.

§Example
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
assert_eq!(max, (-max).wrapping_abs());
Run
1.64.0 (const: 1.64.0) · source

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

Computes the absolute value of self without any wrapping or panicking.

§Example

let u_pos = NonZeroUsize::new(1)?;
let i_pos = NonZeroIsize::new(1)?;
let i_neg = NonZeroIsize::new(-1)?;
let i_min = NonZeroIsize::new(isize::MIN)?;
let u_max = NonZeroUsize::new(usize::MAX / 2 + 1)?;

assert_eq!(u_pos, i_pos.unsigned_abs());
assert_eq!(u_pos, i_neg.unsigned_abs());
assert_eq!(u_max, i_min.unsigned_abs());
Run
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 number is negative.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
Run
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 number is positive.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
Run
1.71.0 (const: 1.71.0) · source

pub const fn checked_neg(self) -> Option<NonZero<isize>>

Checked negation. Computes -self, returning None if self == NonZeroIsize::MIN.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
Run
1.71.0 (const: 1.71.0) · source

pub const fn overflowing_neg(self) -> (NonZero<isize>, bool)

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

See isize::overflowing_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
assert_eq!(min.overflowing_neg(), (min, true));
Run
1.71.0 (const: 1.71.0) · source

pub const fn saturating_neg(self) -> NonZero<isize>

Saturating negation. Computes -self, returning NonZeroIsize::MAX if self == NonZeroIsize::MIN instead of overflowing.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;
let min = NonZeroIsize::new(isize::MIN)?;
let min_plus_one = NonZeroIsize::new(isize::MIN + 1)?;
let max = NonZeroIsize::new(isize::MAX)?;

assert_eq!(pos_five.saturating_neg(), neg_five);
assert_eq!(min.saturating_neg(), max);
assert_eq!(max.saturating_neg(), min_plus_one);
Run
1.71.0 (const: 1.71.0) · source

pub const fn wrapping_neg(self) -> NonZero<isize>

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

See isize::wrapping_neg for documentation on overflow behaviour.

§Example
let pos_five = NonZeroIsize::new(5)?;
let neg_five = NonZeroIsize::new(-5)?;
let min = NonZeroIsize::new(isize::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let two = NonZeroIsize::new(2)?;
let four = NonZeroIsize::new(4)?;
let max = NonZeroIsize::new(isize::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_mul(self, other: NonZero<isize>) -> NonZero<isize>

Multiplies two non-zero integers together. Return NonZeroIsize::MAX on overflow.

§Examples
let two = NonZeroIsize::new(2)?;
let four = NonZeroIsize::new(4)?;
let max = NonZeroIsize::new(isize::MAX)?;

assert_eq!(four, two.saturating_mul(two));
assert_eq!(max, four.saturating_mul(max));
Run
source

pub const unsafe fn unchecked_mul(self, other: NonZero<isize>) -> NonZero<isize>

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

Multiplies two non-zero integers together, assuming overflow cannot occur. Overflow is unchecked, and it is undefined behaviour to overflow even if the result would wrap to a non-zero value. The behaviour is undefined as soon as self * rhs > isize::MAX, or self * rhs < isize::MIN.

§Examples
#![feature(nonzero_ops)]

let two = NonZeroIsize::new(2)?;
let four = NonZeroIsize::new(4)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
Run
1.64.0 (const: 1.64.0) · source

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

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

§Examples
let three = NonZeroIsize::new(3)?;
let twenty_seven = NonZeroIsize::new(27)?;
let half_max = NonZeroIsize::new(isize::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
Run
1.64.0 (const: 1.64.0) · source

pub const fn saturating_pow(self, other: u32) -> NonZero<isize>

Raise non-zero value to an integer power. Return NonZeroIsize::MIN or NonZeroIsize::MAX on overflow.

§Examples
let three = NonZeroIsize::new(3)?;
let twenty_seven = NonZeroIsize::new(27)?;
let max = NonZeroIsize::new(isize::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));
Run

Trait Implementations§

1.34.0 · source§

impl Binary for NonZero<i128>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Binary for NonZero<i16>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Binary for NonZero<i32>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Binary for NonZero<i64>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Binary for NonZero<i8>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Binary for NonZero<isize>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<u128>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<u16>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<u32>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<u64>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<u8>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Binary for NonZero<usize>

source§

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

Formats the value using the given formatter.
1.45.0 · source§

impl BitOr<NonZero<i128>> for i128

§

type Output = NonZero<i128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i128>) -> <i128 as BitOr<NonZero<i128>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<i16>> for i16

§

type Output = NonZero<i16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i16>) -> <i16 as BitOr<NonZero<i16>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<i32>> for i32

§

type Output = NonZero<i32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i32>) -> <i32 as BitOr<NonZero<i32>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<i64>> for i64

§

type Output = NonZero<i64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i64>) -> <i64 as BitOr<NonZero<i64>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<i8>> for i8

§

type Output = NonZero<i8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i8>) -> <i8 as BitOr<NonZero<i8>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<isize>> for isize

§

type Output = NonZero<isize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<isize>) -> <isize as BitOr<NonZero<isize>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<u128>> for u128

§

type Output = NonZero<u128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u128>) -> <u128 as BitOr<NonZero<u128>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<u16>> for u16

§

type Output = NonZero<u16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u16>) -> <u16 as BitOr<NonZero<u16>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<u32>> for u32

§

type Output = NonZero<u32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u32>) -> <u32 as BitOr<NonZero<u32>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<u64>> for u64

§

type Output = NonZero<u64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u64>) -> <u64 as BitOr<NonZero<u64>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<u8>> for u8

§

type Output = NonZero<u8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u8>) -> <u8 as BitOr<NonZero<u8>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<NonZero<usize>> for usize

§

type Output = NonZero<usize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<usize>) -> <usize as BitOr<NonZero<usize>>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<i128> for NonZero<i128>

§

type Output = NonZero<i128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: i128) -> <NonZero<i128> as BitOr<i128>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<i16> for NonZero<i16>

§

type Output = NonZero<i16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: i16) -> <NonZero<i16> as BitOr<i16>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<i32> for NonZero<i32>

§

type Output = NonZero<i32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: i32) -> <NonZero<i32> as BitOr<i32>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<i64> for NonZero<i64>

§

type Output = NonZero<i64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: i64) -> <NonZero<i64> as BitOr<i64>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<i8> for NonZero<i8>

§

type Output = NonZero<i8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: i8) -> <NonZero<i8> as BitOr<i8>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<isize> for NonZero<isize>

§

type Output = NonZero<isize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: isize) -> <NonZero<isize> as BitOr<isize>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<u128> for NonZero<u128>

§

type Output = NonZero<u128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u128) -> <NonZero<u128> as BitOr<u128>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<u16> for NonZero<u16>

§

type Output = NonZero<u16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u16) -> <NonZero<u16> as BitOr<u16>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<u32> for NonZero<u32>

§

type Output = NonZero<u32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u32) -> <NonZero<u32> as BitOr<u32>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<u64> for NonZero<u64>

§

type Output = NonZero<u64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u64) -> <NonZero<u64> as BitOr<u64>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<u8> for NonZero<u8>

§

type Output = NonZero<u8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: u8) -> <NonZero<u8> as BitOr<u8>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<usize> for NonZero<usize>

§

type Output = NonZero<usize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: usize) -> <NonZero<usize> as BitOr<usize>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<i128>

§

type Output = NonZero<i128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i128>) -> <NonZero<i128> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<i16>

§

type Output = NonZero<i16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i16>) -> <NonZero<i16> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<i32>

§

type Output = NonZero<i32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i32>) -> <NonZero<i32> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<i64>

§

type Output = NonZero<i64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i64>) -> <NonZero<i64> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<i8>

§

type Output = NonZero<i8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<i8>) -> <NonZero<i8> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<isize>

§

type Output = NonZero<isize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<isize>) -> <NonZero<isize> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<u128>

§

type Output = NonZero<u128>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u128>) -> <NonZero<u128> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<u16>

§

type Output = NonZero<u16>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u16>) -> <NonZero<u16> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<u32>

§

type Output = NonZero<u32>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u32>) -> <NonZero<u32> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<u64>

§

type Output = NonZero<u64>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u64>) -> <NonZero<u64> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<u8>

§

type Output = NonZero<u8>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<u8>) -> <NonZero<u8> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZero<usize>

§

type Output = NonZero<usize>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<usize>) -> <NonZero<usize> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOrAssign<i128> for NonZero<i128>

source§

fn bitor_assign(&mut self, rhs: i128)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<i16> for NonZero<i16>

source§

fn bitor_assign(&mut self, rhs: i16)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<i32> for NonZero<i32>

source§

fn bitor_assign(&mut self, rhs: i32)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<i64> for NonZero<i64>

source§

fn bitor_assign(&mut self, rhs: i64)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<i8> for NonZero<i8>

source§

fn bitor_assign(&mut self, rhs: i8)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<isize> for NonZero<isize>

source§

fn bitor_assign(&mut self, rhs: isize)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<u128> for NonZero<u128>

source§

fn bitor_assign(&mut self, rhs: u128)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<u16> for NonZero<u16>

source§

fn bitor_assign(&mut self, rhs: u16)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<u32> for NonZero<u32>

source§

fn bitor_assign(&mut self, rhs: u32)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<u64> for NonZero<u64>

source§

fn bitor_assign(&mut self, rhs: u64)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<u8> for NonZero<u8>

source§

fn bitor_assign(&mut self, rhs: u8)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign<usize> for NonZero<usize>

source§

fn bitor_assign(&mut self, rhs: usize)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<i128>

source§

fn bitor_assign(&mut self, rhs: NonZero<i128>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<i16>

source§

fn bitor_assign(&mut self, rhs: NonZero<i16>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<i32>

source§

fn bitor_assign(&mut self, rhs: NonZero<i32>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<i64>

source§

fn bitor_assign(&mut self, rhs: NonZero<i64>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<i8>

source§

fn bitor_assign(&mut self, rhs: NonZero<i8>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<isize>

source§

fn bitor_assign(&mut self, rhs: NonZero<isize>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<u128>

source§

fn bitor_assign(&mut self, rhs: NonZero<u128>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<u16>

source§

fn bitor_assign(&mut self, rhs: NonZero<u16>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<u32>

source§

fn bitor_assign(&mut self, rhs: NonZero<u32>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<u64>

source§

fn bitor_assign(&mut self, rhs: NonZero<u64>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<u8>

source§

fn bitor_assign(&mut self, rhs: NonZero<u8>)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZero<usize>

source§

fn bitor_assign(&mut self, rhs: NonZero<usize>)

Performs the |= operation. Read more
1.34.0 · source§

impl Clone for NonZero<i128>

source§

fn clone(&self) -> NonZero<i128>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Clone for NonZero<i16>

source§

fn clone(&self) -> NonZero<i16>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Clone for NonZero<i32>

source§

fn clone(&self) -> NonZero<i32>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Clone for NonZero<i64>

source§

fn clone(&self) -> NonZero<i64>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Clone for NonZero<i8>

source§

fn clone(&self) -> NonZero<i8>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Clone for NonZero<isize>

source§

fn clone(&self) -> NonZero<isize>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<u128>

source§

fn clone(&self) -> NonZero<u128>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<u16>

source§

fn clone(&self) -> NonZero<u16>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<u32>

source§

fn clone(&self) -> NonZero<u32>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<u64>

source§

fn clone(&self) -> NonZero<u64>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<u8>

source§

fn clone(&self) -> NonZero<u8>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.28.0 · source§

impl Clone for NonZero<usize>

source§

fn clone(&self) -> NonZero<usize>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.34.0 · source§

impl Debug for NonZero<i128>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Debug for NonZero<i16>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Debug for NonZero<i32>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Debug for NonZero<i64>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Debug for NonZero<i8>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Debug for NonZero<isize>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<u128>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<u16>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<u32>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<u64>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<u8>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Debug for NonZero<usize>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<i128>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<i16>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<i32>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<i64>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<i8>

source§

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

Formats the value using the given formatter. Read more
1.34.0 · source§

impl Display for NonZero<isize>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<u128>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<u16>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<u32>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<u64>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<u8>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl Display for NonZero<usize>

source§

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

Formats the value using the given formatter. Read more
1.51.0 · source§

impl Div<NonZero<u128>> for u128

source§

fn div(self, other: NonZero<u128>) -> u128

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = u128

The resulting type after applying the / operator.
1.51.0 · source§

impl Div<NonZero<u16>> for u16

source§

fn div(self, other: NonZero<u16>) -> u16

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = u16

The resulting type after applying the / operator.
1.51.0 · source§

impl Div<NonZero<u32>> for u32

source§

fn div(self, other: NonZero<u32>) -> u32

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = u32

The resulting type after applying the / operator.
1.51.0 · source§

impl Div<NonZero<u64>> for u64

source§

fn div(self, other: NonZero<u64>) -> u64

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = u64

The resulting type after applying the / operator.
1.51.0 · source§

impl Div<NonZero<u8>> for u8

source§

fn div(self, other: NonZero<u8>) -> u8

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = u8

The resulting type after applying the / operator.
1.51.0 · source§

impl Div<NonZero<usize>> for usize

source§

fn div(self, other: NonZero<usize>) -> usize

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = usize

The resulting type after applying the / operator.
source§

impl From<Alignment> for NonZero<usize>

source§

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

Converts to this type from the input type.
1.31.0 · source§

impl From<NonZero<i128>> for i128

source§

fn from(nonzero: NonZero<i128>) -> i128

Converts a NonZeroI128 into an i128

1.41.0 · source§

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

source§

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

Converts NonZeroI16 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI16 to NonZeroI32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI16 to NonZeroI64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI16 to NonZeroIsize losslessly.

1.31.0 · source§

impl From<NonZero<i16>> for i16

source§

fn from(nonzero: NonZero<i16>) -> i16

Converts a NonZeroI16 into an i16

1.41.0 · source§

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

source§

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

Converts NonZeroI32 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI32 to NonZeroI64 losslessly.

1.31.0 · source§

impl From<NonZero<i32>> for i32

source§

fn from(nonzero: NonZero<i32>) -> i32

Converts a NonZeroI32 into an i32

1.41.0 · source§

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

source§

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

Converts NonZeroI64 to NonZeroI128 losslessly.

1.31.0 · source§

impl From<NonZero<i64>> for i64

source§

fn from(nonzero: NonZero<i64>) -> i64

Converts a NonZeroI64 into an i64

1.41.0 · source§

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

source§

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

Converts NonZeroI8 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI8 to NonZeroI16 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI8 to NonZeroI32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI8 to NonZeroI64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroI8 to NonZeroIsize losslessly.

1.31.0 · source§

impl From<NonZero<i8>> for i8

source§

fn from(nonzero: NonZero<i8>) -> i8

Converts a NonZeroI8 into an i8

1.31.0 · source§

impl From<NonZero<isize>> for isize

source§

fn from(nonzero: NonZero<isize>) -> isize

Converts a NonZeroIsize into an isize

1.31.0 · source§

impl From<NonZero<u128>> for u128

source§

fn from(nonzero: NonZero<u128>) -> u128

Converts a NonZeroU128 into an u128

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroI32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroI64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroU128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroU32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroU64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU16 to NonZeroUsize losslessly.

1.31.0 · source§

impl From<NonZero<u16>> for u16

source§

fn from(nonzero: NonZero<u16>) -> u16

Converts a NonZeroU16 into an u16

1.41.0 · source§

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

source§

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

Converts NonZeroU32 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU32 to NonZeroI64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU32 to NonZeroU128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU32 to NonZeroU64 losslessly.

1.31.0 · source§

impl From<NonZero<u32>> for u32

source§

fn from(nonzero: NonZero<u32>) -> u32

Converts a NonZeroU32 into an u32

1.41.0 · source§

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

source§

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

Converts NonZeroU64 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU64 to NonZeroU128 losslessly.

1.31.0 · source§

impl From<NonZero<u64>> for u64

source§

fn from(nonzero: NonZero<u64>) -> u64

Converts a NonZeroU64 into an u64

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroI128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroI16 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroI32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroI64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroIsize losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroU128 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroU16 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroU32 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroU64 losslessly.

1.41.0 · source§

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

source§

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

Converts NonZeroU8 to NonZeroUsize losslessly.

1.31.0 · source§

impl From<NonZero<u8>> for u8

source§

fn from(nonzero: NonZero<u8>) -> u8

Converts a NonZeroU8 into an u8

1.31.0 · source§

impl From<NonZero<usize>> for usize

source§

fn from(nonzero: NonZero<usize>) -> usize

Converts a NonZeroUsize into an usize

1.35.0 · source§

impl FromStr for NonZero<i128>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<i128>, <NonZero<i128> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<i16>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<i16>, <NonZero<i16> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<i32>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<i32>, <NonZero<i32> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<i64>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<i64>, <NonZero<i64> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<i8>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<i8>, <NonZero<i8> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<isize>

§

type Err = ParseIntError

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

fn from_str( src: &str ) -> Result<NonZero<isize>, <NonZero<isize> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<u128>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<u128>, <NonZero<u128> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<u16>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<u16>, <NonZero<u16> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<u32>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<u32>, <NonZero<u32> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<u64>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<u64>, <NonZero<u64> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<u8>

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZero<u8>, <NonZero<u8> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.35.0 · source§

impl FromStr for NonZero<usize>

§

type Err = ParseIntError

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

fn from_str( src: &str ) -> Result<NonZero<usize>, <NonZero<usize> as FromStr>::Err>

Parses a string s to return a value of this type. Read more
1.34.0 · source§

impl Hash for NonZero<i128>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl Hash for NonZero<i16>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl Hash for NonZero<i32>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl Hash for NonZero<i64>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl Hash for NonZero<i8>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl Hash for NonZero<isize>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<u128>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<u16>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<u32>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<u64>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<u8>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.28.0 · source§

impl Hash for NonZero<usize>

source§

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

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

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

Feeds a slice of this type into the given Hasher. Read more
1.34.0 · source§

impl LowerHex for NonZero<i128>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl LowerHex for NonZero<i16>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl LowerHex for NonZero<i32>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl LowerHex for NonZero<i64>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl LowerHex for NonZero<i8>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl LowerHex for NonZero<isize>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<u128>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<u16>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<u32>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<u64>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<u8>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl LowerHex for NonZero<usize>

source§

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

Formats the value using the given formatter.
1.71.0 · source§

impl Neg for &NonZero<i128>

§

type Output = <NonZero<i128> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<i128> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for &NonZero<i16>

§

type Output = <NonZero<i16> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<i16> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for &NonZero<i32>

§

type Output = <NonZero<i32> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<i32> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for &NonZero<i64>

§

type Output = <NonZero<i64> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<i64> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for &NonZero<i8>

§

type Output = <NonZero<i8> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<i8> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for &NonZero<isize>

§

type Output = <NonZero<isize> as Neg>::Output

The resulting type after applying the - operator.
source§

fn neg(self) -> <NonZero<isize> as Neg>::Output

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<i128>

§

type Output = NonZero<i128>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<i128>

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<i16>

§

type Output = NonZero<i16>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<i16>

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<i32>

§

type Output = NonZero<i32>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<i32>

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<i64>

§

type Output = NonZero<i64>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<i64>

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<i8>

§

type Output = NonZero<i8>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<i8>

Performs the unary - operation. Read more
1.71.0 · source§

impl Neg for NonZero<isize>

§

type Output = NonZero<isize>

The resulting type after applying the - operator.
source§

fn neg(self) -> NonZero<isize>

Performs the unary - operation. Read more
1.34.0 · source§

impl Octal for NonZero<i128>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Octal for NonZero<i16>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Octal for NonZero<i32>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Octal for NonZero<i64>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Octal for NonZero<i8>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Octal for NonZero<isize>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<u128>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<u16>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<u32>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<u64>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<u8>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl Octal for NonZero<usize>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Ord for NonZero<i128>

source§

fn cmp(&self, other: &NonZero<i128>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<i128>) -> NonZero<i128>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<i128>) -> NonZero<i128>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<i128>, max: NonZero<i128>) -> NonZero<i128>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl Ord for NonZero<i16>

source§

fn cmp(&self, other: &NonZero<i16>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<i16>) -> NonZero<i16>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<i16>) -> NonZero<i16>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<i16>, max: NonZero<i16>) -> NonZero<i16>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl Ord for NonZero<i32>

source§

fn cmp(&self, other: &NonZero<i32>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<i32>) -> NonZero<i32>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<i32>) -> NonZero<i32>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<i32>, max: NonZero<i32>) -> NonZero<i32>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl Ord for NonZero<i64>

source§

fn cmp(&self, other: &NonZero<i64>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<i64>) -> NonZero<i64>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<i64>) -> NonZero<i64>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<i64>, max: NonZero<i64>) -> NonZero<i64>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl Ord for NonZero<i8>

source§

fn cmp(&self, other: &NonZero<i8>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<i8>) -> NonZero<i8>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<i8>) -> NonZero<i8>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<i8>, max: NonZero<i8>) -> NonZero<i8>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl Ord for NonZero<isize>

source§

fn cmp(&self, other: &NonZero<isize>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<isize>) -> NonZero<isize>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<isize>) -> NonZero<isize>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<isize>, max: NonZero<isize>) -> NonZero<isize>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<u128>

source§

fn cmp(&self, other: &NonZero<u128>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<u128>) -> NonZero<u128>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<u128>) -> NonZero<u128>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<u128>, max: NonZero<u128>) -> NonZero<u128>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<u16>

source§

fn cmp(&self, other: &NonZero<u16>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<u16>) -> NonZero<u16>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<u16>) -> NonZero<u16>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<u16>, max: NonZero<u16>) -> NonZero<u16>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<u32>

source§

fn cmp(&self, other: &NonZero<u32>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<u32>) -> NonZero<u32>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<u32>) -> NonZero<u32>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<u32>, max: NonZero<u32>) -> NonZero<u32>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<u64>

source§

fn cmp(&self, other: &NonZero<u64>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<u64>) -> NonZero<u64>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<u64>) -> NonZero<u64>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<u64>, max: NonZero<u64>) -> NonZero<u64>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<u8>

source§

fn cmp(&self, other: &NonZero<u8>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<u8>) -> NonZero<u8>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<u8>) -> NonZero<u8>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<u8>, max: NonZero<u8>) -> NonZero<u8>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl Ord for NonZero<usize>

source§

fn cmp(&self, other: &NonZero<usize>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<usize>) -> NonZero<usize>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<usize>) -> NonZero<usize>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<usize>, max: NonZero<usize>) -> NonZero<usize>

Restrict a value to a certain interval. Read more
1.34.0 · source§

impl PartialEq for NonZero<i128>

source§

fn eq(&self, other: &NonZero<i128>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<i128>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialEq for NonZero<i16>

source§

fn eq(&self, other: &NonZero<i16>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<i16>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialEq for NonZero<i32>

source§

fn eq(&self, other: &NonZero<i32>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<i32>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialEq for NonZero<i64>

source§

fn eq(&self, other: &NonZero<i64>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<i64>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialEq for NonZero<i8>

source§

fn eq(&self, other: &NonZero<i8>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<i8>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialEq for NonZero<isize>

source§

fn eq(&self, other: &NonZero<isize>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<isize>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<u128>

source§

fn eq(&self, other: &NonZero<u128>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<u128>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<u16>

source§

fn eq(&self, other: &NonZero<u16>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<u16>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<u32>

source§

fn eq(&self, other: &NonZero<u32>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<u32>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<u64>

source§

fn eq(&self, other: &NonZero<u64>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<u64>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<u8>

source§

fn eq(&self, other: &NonZero<u8>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<u8>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl PartialEq for NonZero<usize>

source§

fn eq(&self, other: &NonZero<usize>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<usize>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.34.0 · source§

impl PartialOrd for NonZero<i128>

source§

fn partial_cmp(&self, other: &NonZero<i128>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<i128>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<i128>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<i128>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<i128>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.34.0 · source§

impl PartialOrd for NonZero<i16>

source§

fn partial_cmp(&self, other: &NonZero<i16>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<i16>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<i16>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<i16>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<i16>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.34.0 · source§

impl PartialOrd for NonZero<i32>

source§

fn partial_cmp(&self, other: &NonZero<i32>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<i32>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<i32>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<i32>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<i32>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.34.0 · source§

impl PartialOrd for NonZero<i64>

source§

fn partial_cmp(&self, other: &NonZero<i64>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<i64>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<i64>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<i64>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<i64>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.34.0 · source§

impl PartialOrd for NonZero<i8>

source§

fn partial_cmp(&self, other: &NonZero<i8>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<i8>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<i8>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<i8>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<i8>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.34.0 · source§

impl PartialOrd for NonZero<isize>

source§

fn partial_cmp(&self, other: &NonZero<isize>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<isize>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<isize>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<isize>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<isize>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<u128>

source§

fn partial_cmp(&self, other: &NonZero<u128>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<u128>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<u128>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<u128>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<u128>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<u16>

source§

fn partial_cmp(&self, other: &NonZero<u16>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<u16>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<u16>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<u16>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<u16>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<u32>

source§

fn partial_cmp(&self, other: &NonZero<u32>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<u32>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<u32>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<u32>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<u32>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<u64>

source§

fn partial_cmp(&self, other: &NonZero<u64>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<u64>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<u64>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<u64>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<u64>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<u8>

source§

fn partial_cmp(&self, other: &NonZero<u8>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<u8>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<u8>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<u8>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<u8>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.28.0 · source§

impl PartialOrd for NonZero<usize>

source§

fn partial_cmp(&self, other: &NonZero<usize>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<usize>) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<usize>) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<usize>) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<usize>) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.51.0 · source§

impl Rem<NonZero<u128>> for u128

source§

fn rem(self, other: NonZero<u128>) -> u128

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = u128

The resulting type after applying the % operator.
1.51.0 · source§

impl Rem<NonZero<u16>> for u16

source§

fn rem(self, other: NonZero<u16>) -> u16

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = u16

The resulting type after applying the % operator.
1.51.0 · source§

impl Rem<NonZero<u32>> for u32

source§

fn rem(self, other: NonZero<u32>) -> u32

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = u32

The resulting type after applying the % operator.
1.51.0 · source§

impl Rem<NonZero<u64>> for u64

source§

fn rem(self, other: NonZero<u64>) -> u64

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = u64

The resulting type after applying the % operator.
1.51.0 · source§

impl Rem<NonZero<u8>> for u8

source§

fn rem(self, other: NonZero<u8>) -> u8

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = u8

The resulting type after applying the % operator.
1.51.0 · source§

impl Rem<NonZero<usize>> for usize

source§

fn rem(self, other: NonZero<usize>) -> usize

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = usize

The resulting type after applying the % operator.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<i16>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<i32>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<i64>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<i8>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<isize>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<u128>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<u16>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<u32>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<u64>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<u8>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i128>> for NonZero<usize>

source§

fn try_from( value: NonZero<i128> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<i128>>>::Error>

Attempts to convert NonZeroI128 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<i8>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<u128>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<u16>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<u32>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<u64>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<u8>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i16>> for NonZero<usize>

source§

fn try_from( value: NonZero<i16> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<i16>>>::Error>

Attempts to convert NonZeroI16 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<i16>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<i8>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<isize>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<u128>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<u16>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<u32>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<u64>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<u8>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i32>> for NonZero<usize>

source§

fn try_from( value: NonZero<i32> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<i32>>>::Error>

Attempts to convert NonZeroI32 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<i16>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<i32>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<i8>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<isize>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<u128>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<u16>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<u32>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<u64>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<u8>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i64>> for NonZero<usize>

source§

fn try_from( value: NonZero<i64> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<i64>>>::Error>

Attempts to convert NonZeroI64 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<u128>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<u16>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<u32>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<u64>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<u8>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<i8>> for NonZero<usize>

source§

fn try_from( value: NonZero<i8> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<i8>>>::Error>

Attempts to convert NonZeroI8 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<i128>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<i128>, <NonZero<i128> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroI128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<i16>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<i32>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<i64>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<i8>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<u128>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<u16>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<u32>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<u64>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<u8>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<isize>> for NonZero<usize>

source§

fn try_from( value: NonZero<isize> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<isize>>>::Error>

Attempts to convert NonZeroIsize to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<i128>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<i128>, <NonZero<i128> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroI128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<i16>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<i32>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<i64>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<i8>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<isize>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<u16>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<u32>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<u64>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<u8>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u128>> for NonZero<usize>

source§

fn try_from( value: NonZero<u128> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<u128>>>::Error>

Attempts to convert NonZeroU128 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u16>> for NonZero<i16>

source§

fn try_from( value: NonZero<u16> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<u16>>>::Error>

Attempts to convert NonZeroU16 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u16>> for NonZero<i8>

source§

fn try_from( value: NonZero<u16> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<u16>>>::Error>

Attempts to convert NonZeroU16 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u16>> for NonZero<isize>

source§

fn try_from( value: NonZero<u16> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<u16>>>::Error>

Attempts to convert NonZeroU16 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u16>> for NonZero<u8>

source§

fn try_from( value: NonZero<u16> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<u16>>>::Error>

Attempts to convert NonZeroU16 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<i16>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<i32>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<i8>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<isize>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<u16>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<u8>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u32>> for NonZero<usize>

source§

fn try_from( value: NonZero<u32> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<u32>>>::Error>

Attempts to convert NonZeroU32 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<i16>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<i32>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<i64>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<i8>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<isize>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<u16>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<u32>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<u8>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u64>> for NonZero<usize>

source§

fn try_from( value: NonZero<u64> ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<NonZero<u64>>>::Error>

Attempts to convert NonZeroU64 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<u8>> for NonZero<i8>

source§

fn try_from( value: NonZero<u8> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<u8>>>::Error>

Attempts to convert NonZeroU8 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

impl TryFrom<NonZero<usize>> for Alignment

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from( align: NonZero<usize> ) -> Result<Alignment, <Alignment as TryFrom<NonZero<usize>>>::Error>

Performs the conversion.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<i128>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<i128>, <NonZero<i128> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroI128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<i16>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<i32>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<i64>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<i8>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<isize>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<u128>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<u16>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<u32>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<u64>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZero<usize>> for NonZero<u8>

source§

fn try_from( value: NonZero<usize> ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<NonZero<usize>>>::Error>

Attempts to convert NonZeroUsize to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<i128> for NonZero<i128>

source§

fn try_from( value: i128 ) -> Result<NonZero<i128>, <NonZero<i128> as TryFrom<i128>>::Error>

Attempts to convert i128 to NonZeroI128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<i16> for NonZero<i16>

source§

fn try_from( value: i16 ) -> Result<NonZero<i16>, <NonZero<i16> as TryFrom<i16>>::Error>

Attempts to convert i16 to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<i32> for NonZero<i32>

source§

fn try_from( value: i32 ) -> Result<NonZero<i32>, <NonZero<i32> as TryFrom<i32>>::Error>

Attempts to convert i32 to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<i64> for NonZero<i64>

source§

fn try_from( value: i64 ) -> Result<NonZero<i64>, <NonZero<i64> as TryFrom<i64>>::Error>

Attempts to convert i64 to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<i8> for NonZero<i8>

source§

fn try_from( value: i8 ) -> Result<NonZero<i8>, <NonZero<i8> as TryFrom<i8>>::Error>

Attempts to convert i8 to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<isize> for NonZero<isize>

source§

fn try_from( value: isize ) -> Result<NonZero<isize>, <NonZero<isize> as TryFrom<isize>>::Error>

Attempts to convert isize to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<u128> for NonZero<u128>

source§

fn try_from( value: u128 ) -> Result<NonZero<u128>, <NonZero<u128> as TryFrom<u128>>::Error>

Attempts to convert u128 to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<u16> for NonZero<u16>

source§

fn try_from( value: u16 ) -> Result<NonZero<u16>, <NonZero<u16> as TryFrom<u16>>::Error>

Attempts to convert u16 to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<u32> for NonZero<u32>

source§

fn try_from( value: u32 ) -> Result<NonZero<u32>, <NonZero<u32> as TryFrom<u32>>::Error>

Attempts to convert u32 to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<u64> for NonZero<u64>

source§

fn try_from( value: u64 ) -> Result<NonZero<u64>, <NonZero<u64> as TryFrom<u64>>::Error>

Attempts to convert u64 to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<u8> for NonZero<u8>

source§

fn try_from( value: u8 ) -> Result<NonZero<u8>, <NonZero<u8> as TryFrom<u8>>::Error>

Attempts to convert u8 to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<usize> for NonZero<usize>

source§

fn try_from( value: usize ) -> Result<NonZero<usize>, <NonZero<usize> as TryFrom<usize>>::Error>

Attempts to convert usize to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.34.0 · source§

impl UpperHex for NonZero<i128>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl UpperHex for NonZero<i16>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl UpperHex for NonZero<i32>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl UpperHex for NonZero<i64>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl UpperHex for NonZero<i8>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl UpperHex for NonZero<isize>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<u128>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<u16>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<u32>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<u64>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<u8>

source§

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

Formats the value using the given formatter.
1.28.0 · source§

impl UpperHex for NonZero<usize>

source§

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

Formats the value using the given formatter.
1.34.0 · source§

impl Copy for NonZero<i128>

1.34.0 · source§

impl Copy for NonZero<i16>

1.34.0 · source§

impl Copy for NonZero<i32>

1.34.0 · source§

impl Copy for NonZero<i64>

1.34.0 · source§

impl Copy for NonZero<i8>

1.34.0 · source§

impl Copy for NonZero<isize>

1.28.0 · source§

impl Copy for NonZero<u128>

1.28.0 · source§

impl Copy for NonZero<u16>

1.28.0 · source§

impl Copy for NonZero<u32>

1.28.0 · source§

impl Copy for NonZero<u64>

1.28.0 · source§

impl Copy for NonZero<u8>

1.28.0 · source§

impl Copy for NonZero<usize>

1.34.0 · source§

impl Eq for NonZero<i128>

1.34.0 · source§

impl Eq for NonZero<i16>

1.34.0 · source§

impl Eq for NonZero<i32>

1.34.0 · source§

impl Eq for NonZero<i64>

1.34.0 · source§

impl Eq for NonZero<i8>

1.34.0 · source§

impl Eq for NonZero<isize>

1.28.0 · source§

impl Eq for NonZero<u128>

1.28.0 · source§

impl Eq for NonZero<u16>

1.28.0 · source§

impl Eq for NonZero<u32>

1.28.0 · source§

impl Eq for NonZero<u64>

1.28.0 · source§

impl Eq for NonZero<u8>

1.28.0 · source§

impl Eq for NonZero<usize>

source§

impl StructuralPartialEq for NonZero<i128>

source§

impl StructuralPartialEq for NonZero<i16>

source§

impl StructuralPartialEq for NonZero<i32>

source§

impl StructuralPartialEq for NonZero<i64>

source§

impl StructuralPartialEq for NonZero<i8>

source§

impl StructuralPartialEq for NonZero<isize>

source§

impl StructuralPartialEq for NonZero<u128>

source§

impl StructuralPartialEq for NonZero<u16>

source§

impl StructuralPartialEq for NonZero<u32>

source§

impl StructuralPartialEq for NonZero<u64>

source§

impl StructuralPartialEq for NonZero<u8>

source§

impl StructuralPartialEq for NonZero<usize>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for NonZero<T>
where T: RefUnwindSafe,

§

impl<T> Send for NonZero<T>
where T: Send,

§

impl<T> Sync for NonZero<T>
where T: Sync,

§

impl<T> Unpin for NonZero<T>
where T: Unpin,

§

impl<T> UnwindSafe for NonZero<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.