Struct gclient::ext::sp_core::sp_std::num::NonZero

1.79.0 · source ·
pub struct NonZero<T>(/* private fields */)
where
    T: ZeroablePrimitive;
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:

use core::{mem::size_of, num::NonZero};

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

Implementations§

source§

impl<T> NonZero<T>

1.28.0 (const: 1.47.0) · source

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

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

1.28.0 (const: 1.28.0) · source

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

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.

source

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

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

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

source

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

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

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

§Safety

The referenced value must not be zero.

1.28.0 (const: 1.34.0) · source

pub const fn get(self) -> T

Returns the contained value as a primitive type.

source§

impl NonZero<u8>

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!(NonZero::<u8>::BITS, u8::BITS);
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 = NonZero::<u8>::new(u8::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<u8>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<u8>::new(0b100_0000)?;
let b = NonZero::<u8>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<u8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x82u8)?;
let m = NonZero::new(0xa)?;

assert_eq!(n.rotate_left(2), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<u8>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xau8)?;
let m = NonZero::new(0x82)?;

assert_eq!(n.rotate_right(2), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12u8)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x12)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12u8)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x48)?);
source

pub const fn from_be(x: NonZero<u8>) -> NonZero<u8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU8;
let n = NonZero::new(0x1Au8)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroU8::from_be(n), n)
} else {
    assert_eq!(NonZeroU8::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<u8>) -> NonZero<u8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU8;
let n = NonZero::new(0x1Au8)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroU8::from_le(n), n)
} else {
    assert_eq!(NonZeroU8::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au8)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au8)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<u8>::MIN.get(), 1u8);
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!(NonZero::<u8>::MAX.get(), u8::MAX);
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 = NonZero::new(1u8)?;
let two = NonZero::new(2u8)?;
let max = NonZero::new(u8::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<u8>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1u8)?;
let two = NonZero::new(2u8)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2u8)?;
let three = NonZero::new(3u8)?;
let four = NonZero::new(4u8)?;
let max = NonZero::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() );
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!(NonZero::new(7u8)?.ilog2(), 2);
assert_eq!(NonZero::new(8u8)?.ilog2(), 3);
assert_eq!(NonZero::new(9u8)?.ilog2(), 3);
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!(NonZero::new(99u8)?.ilog10(), 1);
assert_eq!(NonZero::new(100u8)?.ilog10(), 2);
assert_eq!(NonZero::new(101u8)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1u8)?;
let two = NonZero::new(2u8)?;
let four = NonZero::new(4u8)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8u8)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10u8)?;
assert!(!ten.is_power_of_two());
source

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

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10u8)?;
let three = NonZero::new(3u8)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2u8)?;
let four = NonZero::new(4u8)?;
let max = NonZero::new(u8::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<u8>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2u8)?;
let four = NonZero::new(4u8)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3u8)?;
let twenty_seven = NonZero::new(27u8)?;
let half_max = NonZero::new(u8::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<u8>::MAX on overflow.

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

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

impl NonZero<u16>

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!(NonZero::<u16>::BITS, u16::BITS);
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 = NonZero::<u16>::new(u16::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<u16>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<u16>::new(0b100_0000)?;
let b = NonZero::<u16>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<u16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xa003u16)?;
let m = NonZero::new(0x3a)?;

assert_eq!(n.rotate_left(4), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<u16>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x3au16)?;
let m = NonZero::new(0xa003)?;

assert_eq!(n.rotate_right(4), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234u16)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x3412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234u16)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x2c48)?);
source

pub const fn from_be(x: NonZero<u16>) -> NonZero<u16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU16;
let n = NonZero::new(0x1Au16)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroU16::from_be(n), n)
} else {
    assert_eq!(NonZeroU16::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<u16>) -> NonZero<u16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU16;
let n = NonZero::new(0x1Au16)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroU16::from_le(n), n)
} else {
    assert_eq!(NonZeroU16::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au16)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au16)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<u16>::MIN.get(), 1u16);
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!(NonZero::<u16>::MAX.get(), u16::MAX);
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 = NonZero::new(1u16)?;
let two = NonZero::new(2u16)?;
let max = NonZero::new(u16::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<u16>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1u16)?;
let two = NonZero::new(2u16)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2u16)?;
let three = NonZero::new(3u16)?;
let four = NonZero::new(4u16)?;
let max = NonZero::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() );
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!(NonZero::new(7u16)?.ilog2(), 2);
assert_eq!(NonZero::new(8u16)?.ilog2(), 3);
assert_eq!(NonZero::new(9u16)?.ilog2(), 3);
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!(NonZero::new(99u16)?.ilog10(), 1);
assert_eq!(NonZero::new(100u16)?.ilog10(), 2);
assert_eq!(NonZero::new(101u16)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1u16)?;
let two = NonZero::new(2u16)?;
let four = NonZero::new(4u16)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8u16)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10u16)?;
assert!(!ten.is_power_of_two());
source

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

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10u16)?;
let three = NonZero::new(3u16)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2u16)?;
let four = NonZero::new(4u16)?;
let max = NonZero::new(u16::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<u16>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2u16)?;
let four = NonZero::new(4u16)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3u16)?;
let twenty_seven = NonZero::new(27u16)?;
let half_max = NonZero::new(u16::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<u16>::MAX on overflow.

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

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

impl NonZero<u32>

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!(NonZero::<u32>::BITS, u32::BITS);
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 = NonZero::<u32>::new(u32::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<u32>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<u32>::new(0b100_0000)?;
let b = NonZero::<u32>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x10000b3u32)?;
let m = NonZero::new(0xb301)?;

assert_eq!(n.rotate_left(8), m);
source

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

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xb301u32)?;
let m = NonZero::new(0x10000b3)?;

assert_eq!(n.rotate_right(8), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678u32)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x78563412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678u32)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x1e6a2c48)?);
source

pub const fn from_be(x: NonZero<u32>) -> NonZero<u32>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU32;
let n = NonZero::new(0x1Au32)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroU32::from_be(n), n)
} else {
    assert_eq!(NonZeroU32::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<u32>) -> NonZero<u32>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU32;
let n = NonZero::new(0x1Au32)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroU32::from_le(n), n)
} else {
    assert_eq!(NonZeroU32::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au32)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au32)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<u32>::MIN.get(), 1u32);
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!(NonZero::<u32>::MAX.get(), u32::MAX);
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 = NonZero::new(1u32)?;
let two = NonZero::new(2u32)?;
let max = NonZero::new(u32::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<u32>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1u32)?;
let two = NonZero::new(2u32)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2u32)?;
let three = NonZero::new(3u32)?;
let four = NonZero::new(4u32)?;
let max = NonZero::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() );
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!(NonZero::new(7u32)?.ilog2(), 2);
assert_eq!(NonZero::new(8u32)?.ilog2(), 3);
assert_eq!(NonZero::new(9u32)?.ilog2(), 3);
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!(NonZero::new(99u32)?.ilog10(), 1);
assert_eq!(NonZero::new(100u32)?.ilog10(), 2);
assert_eq!(NonZero::new(101u32)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1u32)?;
let two = NonZero::new(2u32)?;
let four = NonZero::new(4u32)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8u32)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10u32)?;
assert!(!ten.is_power_of_two());
source

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

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10u32)?;
let three = NonZero::new(3u32)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2u32)?;
let four = NonZero::new(4u32)?;
let max = NonZero::new(u32::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<u32>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2u32)?;
let four = NonZero::new(4u32)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3u32)?;
let twenty_seven = NonZero::new(27u32)?;
let half_max = NonZero::new(u32::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<u32>::MAX on overflow.

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

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

impl NonZero<u64>

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!(NonZero::<u64>::BITS, u64::BITS);
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 = NonZero::<u64>::new(u64::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<u64>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<u64>::new(0b100_0000)?;
let b = NonZero::<u64>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<u64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xaa00000000006e1u64)?;
let m = NonZero::new(0x6e10aa)?;

assert_eq!(n.rotate_left(12), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<u64>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x6e10aau64)?;
let m = NonZero::new(0xaa00000000006e1)?;

assert_eq!(n.rotate_right(12), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456u64)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x5634129078563412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456u64)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<u64>) -> NonZero<u64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU64;
let n = NonZero::new(0x1Au64)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroU64::from_be(n), n)
} else {
    assert_eq!(NonZeroU64::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<u64>) -> NonZero<u64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU64;
let n = NonZero::new(0x1Au64)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroU64::from_le(n), n)
} else {
    assert_eq!(NonZeroU64::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au64)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au64)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<u64>::MIN.get(), 1u64);
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!(NonZero::<u64>::MAX.get(), u64::MAX);
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 = NonZero::new(1u64)?;
let two = NonZero::new(2u64)?;
let max = NonZero::new(u64::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<u64>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1u64)?;
let two = NonZero::new(2u64)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2u64)?;
let three = NonZero::new(3u64)?;
let four = NonZero::new(4u64)?;
let max = NonZero::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() );
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!(NonZero::new(7u64)?.ilog2(), 2);
assert_eq!(NonZero::new(8u64)?.ilog2(), 3);
assert_eq!(NonZero::new(9u64)?.ilog2(), 3);
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!(NonZero::new(99u64)?.ilog10(), 1);
assert_eq!(NonZero::new(100u64)?.ilog10(), 2);
assert_eq!(NonZero::new(101u64)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1u64)?;
let two = NonZero::new(2u64)?;
let four = NonZero::new(4u64)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8u64)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10u64)?;
assert!(!ten.is_power_of_two());
source

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

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10u64)?;
let three = NonZero::new(3u64)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2u64)?;
let four = NonZero::new(4u64)?;
let max = NonZero::new(u64::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<u64>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2u64)?;
let four = NonZero::new(4u64)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3u64)?;
let twenty_seven = NonZero::new(27u64)?;
let half_max = NonZero::new(u64::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<u64>::MAX on overflow.

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

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

impl NonZero<u128>

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!(NonZero::<u128>::BITS, u128::BITS);
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 = NonZero::<u128>::new(u128::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<u128>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<u128>::new(0b100_0000)?;
let b = NonZero::<u128>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<u128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x13f40000000000000000000000004f76u128)?;
let m = NonZero::new(0x4f7613f4)?;

assert_eq!(n.rotate_left(16), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<u128>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x4f7613f4u128)?;
let m = NonZero::new(0x13f40000000000000000000000004f76)?;

assert_eq!(n.rotate_right(16), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678901234567890123456789012u128)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x12907856341290785634129078563412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678901234567890123456789012u128)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x48091e6a2c48091e6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<u128>) -> NonZero<u128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU128;
let n = NonZero::new(0x1Au128)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroU128::from_be(n), n)
} else {
    assert_eq!(NonZeroU128::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<u128>) -> NonZero<u128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroU128;
let n = NonZero::new(0x1Au128)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroU128::from_le(n), n)
} else {
    assert_eq!(NonZeroU128::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au128)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Au128)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<u128>::MIN.get(), 1u128);
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!(NonZero::<u128>::MAX.get(), u128::MAX);
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 = NonZero::new(1u128)?;
let two = NonZero::new(2u128)?;
let max = NonZero::new(u128::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<u128>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1u128)?;
let two = NonZero::new(2u128)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2u128)?;
let three = NonZero::new(3u128)?;
let four = NonZero::new(4u128)?;
let max = NonZero::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() );
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!(NonZero::new(7u128)?.ilog2(), 2);
assert_eq!(NonZero::new(8u128)?.ilog2(), 3);
assert_eq!(NonZero::new(9u128)?.ilog2(), 3);
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!(NonZero::new(99u128)?.ilog10(), 1);
assert_eq!(NonZero::new(100u128)?.ilog10(), 2);
assert_eq!(NonZero::new(101u128)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1u128)?;
let two = NonZero::new(2u128)?;
let four = NonZero::new(4u128)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8u128)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10u128)?;
assert!(!ten.is_power_of_two());
source

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

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10u128)?;
let three = NonZero::new(3u128)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2u128)?;
let four = NonZero::new(4u128)?;
let max = NonZero::new(u128::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<u128>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2u128)?;
let four = NonZero::new(4u128)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3u128)?;
let twenty_seven = NonZero::new(27u128)?;
let half_max = NonZero::new(u128::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<u128>::MAX on overflow.

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

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

impl NonZero<usize>

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!(NonZero::<usize>::BITS, usize::BITS);
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 = NonZero::<usize>::new(usize::MAX)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<usize>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<usize>::new(0b100_0000)?;
let b = NonZero::<usize>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<usize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xaa00000000006e1usize)?;
let m = NonZero::new(0x6e10aa)?;

assert_eq!(n.rotate_left(12), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<usize>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x6e10aausize)?;
let m = NonZero::new(0xaa00000000006e1)?;

assert_eq!(n.rotate_right(12), m);
source

pub const fn swap_bytes(self) -> NonZero<usize>

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456usize)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x5634129078563412)?);
source

pub const fn reverse_bits(self) -> NonZero<usize>

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456usize)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<usize>) -> NonZero<usize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroUsize;
let n = NonZero::new(0x1Ausize)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroUsize::from_be(n), n)
} else {
    assert_eq!(NonZeroUsize::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<usize>) -> NonZero<usize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroUsize;
let n = NonZero::new(0x1Ausize)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroUsize::from_le(n), n)
} else {
    assert_eq!(NonZeroUsize::from_le(n), n.swap_bytes())
}
source

pub const fn to_be(self) -> NonZero<usize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ausize)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

pub const fn to_le(self) -> NonZero<usize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ausize)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<usize>::MIN.get(), 1usize);
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!(NonZero::<usize>::MAX.get(), usize::MAX);
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 = NonZero::new(1usize)?;
let two = NonZero::new(2usize)?;
let max = NonZero::new(usize::MAX)?;

assert_eq!(Some(two), one.checked_add(1));
assert_eq!(None, max.checked_add(1));
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 NonZero::<usize>::MAX on overflow.

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

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

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

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

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 = NonZero::new(1usize)?;
let two = NonZero::new(2usize)?;

assert_eq!(two, unsafe { one.unchecked_add(1) });
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 self. 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 = NonZero::new(2usize)?;
let three = NonZero::new(3usize)?;
let four = NonZero::new(4usize)?;
let max = NonZero::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() );
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!(NonZero::new(7usize)?.ilog2(), 2);
assert_eq!(NonZero::new(8usize)?.ilog2(), 3);
assert_eq!(NonZero::new(9usize)?.ilog2(), 3);
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!(NonZero::new(99usize)?.ilog10(), 1);
assert_eq!(NonZero::new(100usize)?.ilog10(), 2);
assert_eq!(NonZero::new(101usize)?.ilog10(), 2);
source

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

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

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 = NonZero::new(1usize)?;
let two = NonZero::new(2usize)?;
let four = NonZero::new(4usize)?;

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
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 = NonZero::new(8usize)?;
assert!(eight.is_power_of_two());
let ten = NonZero::new(10usize)?;
assert!(!ten.is_power_of_two());
source

pub const fn isqrt(self) -> NonZero<usize>

🔬This is a nightly-only experimental API. (isqrt)

Returns the square root of the number, rounded down.

§Examples

Basic usage:

#![feature(isqrt)]
let ten = NonZero::new(10usize)?;
let three = NonZero::new(3usize)?;

assert_eq!(ten.isqrt(), three);
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 = NonZero::new(2usize)?;
let four = NonZero::new(4usize)?;
let max = NonZero::new(usize::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<usize>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2usize)?;
let four = NonZero::new(4usize)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3usize)?;
let twenty_seven = NonZero::new(27usize)?;
let half_max = NonZero::new(usize::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<usize>::MAX on overflow.

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

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

impl NonZero<i8>

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!(NonZero::<i8>::BITS, i8::BITS);
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 = NonZero::<i8>::new(-1i8)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<i8>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<i8>::new(0b100_0000)?;
let b = NonZero::<i8>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<i8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(-0x7ei8)?;
let m = NonZero::new(0xa)?;

assert_eq!(n.rotate_left(2), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<i8>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xai8)?;
let m = NonZero::new(-0x7e)?;

assert_eq!(n.rotate_right(2), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12i8)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x12)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12i8)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x48)?);
source

pub const fn from_be(x: NonZero<i8>) -> NonZero<i8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI8;
let n = NonZero::new(0x1Ai8)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroI8::from_be(n), n)
} else {
    assert_eq!(NonZeroI8::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<i8>) -> NonZero<i8>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI8;
let n = NonZero::new(0x1Ai8)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroI8::from_le(n), n)
} else {
    assert_eq!(NonZeroI8::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai8)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai8)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<i8>::MIN.get(), i8::MIN);
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!(NonZero::<i8>::MAX.get(), i8::MAX);
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 = NonZero::new(1i8)?;
let neg = NonZero::new(-1i8)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<i8>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1i8)?;
let neg = NonZero::new(-1i8)?;
let min = NonZero::new(i8::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1i8)?;
let neg = NonZero::new(-1i8)?;
let min = NonZero::new(i8::MIN)?;
let min_plus = NonZero::new(i8::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1i8)?;
let neg = NonZero::new(-1i8)?;
let min = NonZero::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());
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 = NonZero::new(1u8)?;
let i_pos = NonZero::new(1i8)?;
let i_neg = NonZero::new(-1i8)?;
let i_min = NonZero::new(i8::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5i8)?;
let neg_five = NonZero::new(-5i8)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5i8)?;
let neg_five = NonZero::new(-5i8)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<i8>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5i8)?;
let neg_five = NonZero::new(-5i8)?;
let min = NonZero::new(i8::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<i8>::MAX if self == NonZero::<i8>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5i8)?;
let neg_five = NonZero::new(-5i8)?;
let min = NonZero::new(i8::MIN)?;
let min_plus_one = NonZero::new(i8::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5i8)?;
let neg_five = NonZero::new(-5i8)?;
let min = NonZero::new(i8::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2i8)?;
let four = NonZero::new(4i8)?;
let max = NonZero::new(i8::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<i8>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2i8)?;
let four = NonZero::new(4i8)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3i8)?;
let twenty_seven = NonZero::new(27i8)?;
let half_max = NonZero::new(i8::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<i8>::MIN or NonZero::<i8>::MAX on overflow.

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

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

impl NonZero<i16>

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!(NonZero::<i16>::BITS, i16::BITS);
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 = NonZero::<i16>::new(-1i16)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<i16>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<i16>::new(0b100_0000)?;
let b = NonZero::<i16>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<i16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(-0x5ffdi16)?;
let m = NonZero::new(0x3a)?;

assert_eq!(n.rotate_left(4), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<i16>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x3ai16)?;
let m = NonZero::new(-0x5ffd)?;

assert_eq!(n.rotate_right(4), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234i16)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x3412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234i16)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x2c48)?);
source

pub const fn from_be(x: NonZero<i16>) -> NonZero<i16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI16;
let n = NonZero::new(0x1Ai16)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroI16::from_be(n), n)
} else {
    assert_eq!(NonZeroI16::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<i16>) -> NonZero<i16>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI16;
let n = NonZero::new(0x1Ai16)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroI16::from_le(n), n)
} else {
    assert_eq!(NonZeroI16::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai16)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai16)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<i16>::MIN.get(), i16::MIN);
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!(NonZero::<i16>::MAX.get(), i16::MAX);
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 = NonZero::new(1i16)?;
let neg = NonZero::new(-1i16)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<i16>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1i16)?;
let neg = NonZero::new(-1i16)?;
let min = NonZero::new(i16::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1i16)?;
let neg = NonZero::new(-1i16)?;
let min = NonZero::new(i16::MIN)?;
let min_plus = NonZero::new(i16::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1i16)?;
let neg = NonZero::new(-1i16)?;
let min = NonZero::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());
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 = NonZero::new(1u16)?;
let i_pos = NonZero::new(1i16)?;
let i_neg = NonZero::new(-1i16)?;
let i_min = NonZero::new(i16::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5i16)?;
let neg_five = NonZero::new(-5i16)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5i16)?;
let neg_five = NonZero::new(-5i16)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<i16>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5i16)?;
let neg_five = NonZero::new(-5i16)?;
let min = NonZero::new(i16::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<i16>::MAX if self == NonZero::<i16>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5i16)?;
let neg_five = NonZero::new(-5i16)?;
let min = NonZero::new(i16::MIN)?;
let min_plus_one = NonZero::new(i16::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5i16)?;
let neg_five = NonZero::new(-5i16)?;
let min = NonZero::new(i16::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2i16)?;
let four = NonZero::new(4i16)?;
let max = NonZero::new(i16::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<i16>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2i16)?;
let four = NonZero::new(4i16)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3i16)?;
let twenty_seven = NonZero::new(27i16)?;
let half_max = NonZero::new(i16::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<i16>::MIN or NonZero::<i16>::MAX on overflow.

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

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

impl NonZero<i32>

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!(NonZero::<i32>::BITS, i32::BITS);
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 = NonZero::<i32>::new(-1i32)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<i32>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<i32>::new(0b100_0000)?;
let b = NonZero::<i32>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<i32>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x10000b3i32)?;
let m = NonZero::new(0xb301)?;

assert_eq!(n.rotate_left(8), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<i32>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xb301i32)?;
let m = NonZero::new(0x10000b3)?;

assert_eq!(n.rotate_right(8), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678i32)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x78563412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678i32)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x1e6a2c48)?);
source

pub const fn from_be(x: NonZero<i32>) -> NonZero<i32>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI32;
let n = NonZero::new(0x1Ai32)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroI32::from_be(n), n)
} else {
    assert_eq!(NonZeroI32::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<i32>) -> NonZero<i32>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI32;
let n = NonZero::new(0x1Ai32)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroI32::from_le(n), n)
} else {
    assert_eq!(NonZeroI32::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai32)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai32)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<i32>::MIN.get(), i32::MIN);
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!(NonZero::<i32>::MAX.get(), i32::MAX);
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 = NonZero::new(1i32)?;
let neg = NonZero::new(-1i32)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<i32>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1i32)?;
let neg = NonZero::new(-1i32)?;
let min = NonZero::new(i32::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1i32)?;
let neg = NonZero::new(-1i32)?;
let min = NonZero::new(i32::MIN)?;
let min_plus = NonZero::new(i32::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1i32)?;
let neg = NonZero::new(-1i32)?;
let min = NonZero::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());
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 = NonZero::new(1u32)?;
let i_pos = NonZero::new(1i32)?;
let i_neg = NonZero::new(-1i32)?;
let i_min = NonZero::new(i32::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5i32)?;
let neg_five = NonZero::new(-5i32)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5i32)?;
let neg_five = NonZero::new(-5i32)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<i32>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5i32)?;
let neg_five = NonZero::new(-5i32)?;
let min = NonZero::new(i32::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<i32>::MAX if self == NonZero::<i32>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5i32)?;
let neg_five = NonZero::new(-5i32)?;
let min = NonZero::new(i32::MIN)?;
let min_plus_one = NonZero::new(i32::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5i32)?;
let neg_five = NonZero::new(-5i32)?;
let min = NonZero::new(i32::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2i32)?;
let four = NonZero::new(4i32)?;
let max = NonZero::new(i32::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<i32>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2i32)?;
let four = NonZero::new(4i32)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3i32)?;
let twenty_seven = NonZero::new(27i32)?;
let half_max = NonZero::new(i32::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<i32>::MIN or NonZero::<i32>::MAX on overflow.

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

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

impl NonZero<i64>

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!(NonZero::<i64>::BITS, i64::BITS);
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 = NonZero::<i64>::new(-1i64)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<i64>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<i64>::new(0b100_0000)?;
let b = NonZero::<i64>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<i64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xaa00000000006e1i64)?;
let m = NonZero::new(0x6e10aa)?;

assert_eq!(n.rotate_left(12), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<i64>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x6e10aai64)?;
let m = NonZero::new(0xaa00000000006e1)?;

assert_eq!(n.rotate_right(12), m);
source

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

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456i64)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x5634129078563412)?);
source

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456i64)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<i64>) -> NonZero<i64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI64;
let n = NonZero::new(0x1Ai64)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroI64::from_be(n), n)
} else {
    assert_eq!(NonZeroI64::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<i64>) -> NonZero<i64>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI64;
let n = NonZero::new(0x1Ai64)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroI64::from_le(n), n)
} else {
    assert_eq!(NonZeroI64::from_le(n), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai64)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

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

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai64)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<i64>::MIN.get(), i64::MIN);
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!(NonZero::<i64>::MAX.get(), i64::MAX);
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 = NonZero::new(1i64)?;
let neg = NonZero::new(-1i64)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<i64>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1i64)?;
let neg = NonZero::new(-1i64)?;
let min = NonZero::new(i64::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1i64)?;
let neg = NonZero::new(-1i64)?;
let min = NonZero::new(i64::MIN)?;
let min_plus = NonZero::new(i64::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1i64)?;
let neg = NonZero::new(-1i64)?;
let min = NonZero::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());
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 = NonZero::new(1u64)?;
let i_pos = NonZero::new(1i64)?;
let i_neg = NonZero::new(-1i64)?;
let i_min = NonZero::new(i64::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5i64)?;
let neg_five = NonZero::new(-5i64)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5i64)?;
let neg_five = NonZero::new(-5i64)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<i64>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5i64)?;
let neg_five = NonZero::new(-5i64)?;
let min = NonZero::new(i64::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<i64>::MAX if self == NonZero::<i64>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5i64)?;
let neg_five = NonZero::new(-5i64)?;
let min = NonZero::new(i64::MIN)?;
let min_plus_one = NonZero::new(i64::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5i64)?;
let neg_five = NonZero::new(-5i64)?;
let min = NonZero::new(i64::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2i64)?;
let four = NonZero::new(4i64)?;
let max = NonZero::new(i64::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<i64>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2i64)?;
let four = NonZero::new(4i64)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3i64)?;
let twenty_seven = NonZero::new(27i64)?;
let half_max = NonZero::new(i64::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<i64>::MIN or NonZero::<i64>::MAX on overflow.

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

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

impl NonZero<i128>

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!(NonZero::<i128>::BITS, i128::BITS);
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 = NonZero::<i128>::new(-1i128)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<i128>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<i128>::new(0b100_0000)?;
let b = NonZero::<i128>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<i128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x13f40000000000000000000000004f76i128)?;
let m = NonZero::new(0x4f7613f4)?;

assert_eq!(n.rotate_left(16), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<i128>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x4f7613f4i128)?;
let m = NonZero::new(0x13f40000000000000000000000004f76)?;

assert_eq!(n.rotate_right(16), m);
source

pub const fn swap_bytes(self) -> NonZero<i128>

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678901234567890123456789012i128)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x12907856341290785634129078563412)?);
source

pub const fn reverse_bits(self) -> NonZero<i128>

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x12345678901234567890123456789012i128)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x48091e6a2c48091e6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<i128>) -> NonZero<i128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI128;
let n = NonZero::new(0x1Ai128)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroI128::from_be(n), n)
} else {
    assert_eq!(NonZeroI128::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<i128>) -> NonZero<i128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroI128;
let n = NonZero::new(0x1Ai128)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroI128::from_le(n), n)
} else {
    assert_eq!(NonZeroI128::from_le(n), n.swap_bytes())
}
source

pub const fn to_be(self) -> NonZero<i128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai128)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

pub const fn to_le(self) -> NonZero<i128>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Ai128)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<i128>::MIN.get(), i128::MIN);
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!(NonZero::<i128>::MAX.get(), i128::MAX);
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 = NonZero::new(1i128)?;
let neg = NonZero::new(-1i128)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<i128>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1i128)?;
let neg = NonZero::new(-1i128)?;
let min = NonZero::new(i128::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1i128)?;
let neg = NonZero::new(-1i128)?;
let min = NonZero::new(i128::MIN)?;
let min_plus = NonZero::new(i128::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1i128)?;
let neg = NonZero::new(-1i128)?;
let min = NonZero::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());
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 = NonZero::new(1u128)?;
let i_pos = NonZero::new(1i128)?;
let i_neg = NonZero::new(-1i128)?;
let i_min = NonZero::new(i128::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5i128)?;
let neg_five = NonZero::new(-5i128)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5i128)?;
let neg_five = NonZero::new(-5i128)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<i128>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5i128)?;
let neg_five = NonZero::new(-5i128)?;
let min = NonZero::new(i128::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<i128>::MAX if self == NonZero::<i128>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5i128)?;
let neg_five = NonZero::new(-5i128)?;
let min = NonZero::new(i128::MIN)?;
let min_plus_one = NonZero::new(i128::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5i128)?;
let neg_five = NonZero::new(-5i128)?;
let min = NonZero::new(i128::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2i128)?;
let four = NonZero::new(4i128)?;
let max = NonZero::new(i128::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<i128>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2i128)?;
let four = NonZero::new(4i128)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3i128)?;
let twenty_seven = NonZero::new(27i128)?;
let half_max = NonZero::new(i128::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<i128>::MIN or NonZero::<i128>::MAX on overflow.

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

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

impl NonZero<isize>

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!(NonZero::<isize>::BITS, isize::BITS);
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 = NonZero::<isize>::new(-1isize)?;

assert_eq!(n.leading_zeros(), 0);
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 = NonZero::<isize>::new(0b0101000)?;

assert_eq!(n.trailing_zeros(), 3);
source

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

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

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

§Examples

Basic usage:

#![feature(non_zero_count_ones)]

let a = NonZero::<isize>::new(0b100_0000)?;
let b = NonZero::<isize>::new(0b100_0011)?;

assert_eq!(a.count_ones(), NonZero::new(1)?);
assert_eq!(b.count_ones(), NonZero::new(3)?);
source

pub const fn rotate_left(self, n: u32) -> NonZero<isize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0xaa00000000006e1isize)?;
let m = NonZero::new(0x6e10aa)?;

assert_eq!(n.rotate_left(12), m);
source

pub const fn rotate_right(self, n: u32) -> NonZero<isize>

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

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x6e10aaisize)?;
let m = NonZero::new(0xaa00000000006e1)?;

assert_eq!(n.rotate_right(12), m);
source

pub const fn swap_bytes(self) -> NonZero<isize>

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

Reverses the byte order of the integer.

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456isize)?;
let m = n.swap_bytes();

assert_eq!(m, NonZero::new(0x5634129078563412)?);
source

pub const fn reverse_bits(self) -> NonZero<isize>

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1234567890123456isize)?;
let m = n.reverse_bits();

assert_eq!(m, NonZero::new(0x6a2c48091e6a2c48)?);
source

pub const fn from_be(x: NonZero<isize>) -> NonZero<isize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroIsize;
let n = NonZero::new(0x1Aisize)?;

if cfg!(target_endian = "big") {
    assert_eq!(NonZeroIsize::from_be(n), n)
} else {
    assert_eq!(NonZeroIsize::from_be(n), n.swap_bytes())
}
source

pub const fn from_le(x: NonZero<isize>) -> NonZero<isize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
use std::num::NonZeroIsize;
let n = NonZero::new(0x1Aisize)?;

if cfg!(target_endian = "little") {
    assert_eq!(NonZeroIsize::from_le(n), n)
} else {
    assert_eq!(NonZeroIsize::from_le(n), n.swap_bytes())
}
source

pub const fn to_be(self) -> NonZero<isize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Aisize)?;

if cfg!(target_endian = "big") {
    assert_eq!(n.to_be(), n)
} else {
    assert_eq!(n.to_be(), n.swap_bytes())
}
source

pub const fn to_le(self) -> NonZero<isize>

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

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

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

§Examples

Basic usage:

#![feature(nonzero_bitwise)]
let n = NonZero::new(0x1Aisize)?;

if cfg!(target_endian = "little") {
    assert_eq!(n.to_le(), n)
} else {
    assert_eq!(n.to_le(), n.swap_bytes())
}
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!(NonZero::<isize>::MIN.get(), isize::MIN);
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!(NonZero::<isize>::MAX.get(), isize::MAX);
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 = NonZero::new(1isize)?;
let neg = NonZero::new(-1isize)?;

assert_eq!(pos, pos.abs());
assert_eq!(pos, neg.abs());
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 == NonZero::<isize>::MIN. The result cannot be zero.

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

assert_eq!(Some(pos), neg.checked_abs());
assert_eq!(None, min.checked_abs());
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 = NonZero::new(1isize)?;
let neg = NonZero::new(-1isize)?;
let min = NonZero::new(isize::MIN)?;

assert_eq!((pos, false), pos.overflowing_abs());
assert_eq!((pos, false), neg.overflowing_abs());
assert_eq!((min, true), min.overflowing_abs());
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 = NonZero::new(1isize)?;
let neg = NonZero::new(-1isize)?;
let min = NonZero::new(isize::MIN)?;
let min_plus = NonZero::new(isize::MIN + 1)?;
let max = NonZero::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());
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 = NonZero::new(1isize)?;
let neg = NonZero::new(-1isize)?;
let min = NonZero::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());
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 = NonZero::new(1usize)?;
let i_pos = NonZero::new(1isize)?;
let i_neg = NonZero::new(-1isize)?;
let i_min = NonZero::new(isize::MIN)?;
let u_max = NonZero::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());
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 = NonZero::new(5isize)?;
let neg_five = NonZero::new(-5isize)?;

assert!(pos_five.is_positive());
assert!(!neg_five.is_positive());
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 = NonZero::new(5isize)?;
let neg_five = NonZero::new(-5isize)?;

assert!(neg_five.is_negative());
assert!(!pos_five.is_negative());
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 == NonZero::<isize>::MIN.

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

assert_eq!(pos_five.checked_neg(), Some(neg_five));
assert_eq!(min.checked_neg(), None);
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 = NonZero::new(5isize)?;
let neg_five = NonZero::new(-5isize)?;
let min = NonZero::new(isize::MIN)?;

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

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

Saturating negation. Computes -self, returning NonZero::<isize>::MAX if self == NonZero::<isize>::MIN instead of overflowing.

§Example
let pos_five = NonZero::new(5isize)?;
let neg_five = NonZero::new(-5isize)?;
let min = NonZero::new(isize::MIN)?;
let min_plus_one = NonZero::new(isize::MIN + 1)?;
let max = NonZero::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);
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 = NonZero::new(5isize)?;
let neg_five = NonZero::new(-5isize)?;
let min = NonZero::new(isize::MIN)?;

assert_eq!(pos_five.wrapping_neg(), neg_five);
assert_eq!(min.wrapping_neg(), min);
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 = NonZero::new(2isize)?;
let four = NonZero::new(4isize)?;
let max = NonZero::new(isize::MAX)?;

assert_eq!(Some(four), two.checked_mul(two));
assert_eq!(None, max.checked_mul(two));
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 NonZero::<isize>::MAX on overflow.

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

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

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

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

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 = NonZero::new(2isize)?;
let four = NonZero::new(4isize)?;

assert_eq!(four, unsafe { two.unchecked_mul(two) });
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 = NonZero::new(3isize)?;
let twenty_seven = NonZero::new(27isize)?;
let half_max = NonZero::new(isize::MAX / 2)?;

assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
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 NonZero::<isize>::MIN or NonZero::<isize>::MAX on overflow.

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

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

Trait Implementations§

§

impl AsBytes for NonZero<i128>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<i16>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<i32>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<i64>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<i8>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<isize>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<u128>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<u16>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<u32>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<u64>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<u8>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
§

impl AsBytes for NonZero<usize>

§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
1.28.0 · source§

impl<T> Binary for NonZero<T>

source§

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

Formats the value using the given formatter. Read more
1.45.0 · source§

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

§

type Output = NonZero<T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<T>) -> <T as BitOr<NonZero<T>>>::Output

Performs the | operation. Read more
1.45.0 · source§

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

§

type Output = NonZero<T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: T) -> <NonZero<T> as BitOr<T>>::Output

Performs the | operation. Read more
1.45.0 · source§

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

§

type Output = NonZero<T>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZero<T>) -> <NonZero<T> as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

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

source§

fn bitor_assign(&mut self, rhs: T)

Performs the |= operation. Read more
1.45.0 · source§

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

source§

fn bitor_assign(&mut self, rhs: NonZero<T>)

Performs the |= operation. Read more
1.28.0 · source§

impl<T> Clone for NonZero<T>

source§

fn clone(&self) -> NonZero<T>

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<T> Debug for NonZero<T>

source§

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

Formats the value using the given formatter. Read more
§

impl Decode for NonZero<i128>

§

fn decode<I>(input: &mut I) -> Result<NonZero<i128>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<i16>

§

fn decode<I>(input: &mut I) -> Result<NonZero<i16>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<i32>

§

fn decode<I>(input: &mut I) -> Result<NonZero<i32>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<i64>

§

fn decode<I>(input: &mut I) -> Result<NonZero<i64>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<i8>

§

fn decode<I>(input: &mut I) -> Result<NonZero<i8>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<u128>

§

fn decode<I>(input: &mut I) -> Result<NonZero<u128>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<u16>

§

fn decode<I>(input: &mut I) -> Result<NonZero<u16>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<u32>

§

fn decode<I>(input: &mut I) -> Result<NonZero<u32>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<u64>

§

fn decode<I>(input: &mut I) -> Result<NonZero<u64>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
§

impl Decode for NonZero<u8>

§

fn decode<I>(input: &mut I) -> Result<NonZero<u8>, Error>
where I: Input,

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
source§

impl<'de> Deserialize<'de> for NonZero<i128>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<i128>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<i16>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<i16>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<i32>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<i32>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<i64>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<i64>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<i8>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<i8>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<isize>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<isize>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<u128>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<u128>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<u16>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<u16>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<u32>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<u32>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<u64>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<u64>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<u8>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<u8>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserialize<'de> for NonZero<usize>

source§

fn deserialize<D>( deserializer: D, ) -> Result<NonZero<usize>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
1.28.0 · source§

impl<T> Display for NonZero<T>

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.
1.79.0 · source§

impl DivAssign<NonZero<u128>> for u128

source§

fn div_assign(&mut self, other: NonZero<u128>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

1.79.0 · source§

impl DivAssign<NonZero<u16>> for u16

source§

fn div_assign(&mut self, other: NonZero<u16>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

1.79.0 · source§

impl DivAssign<NonZero<u32>> for u32

source§

fn div_assign(&mut self, other: NonZero<u32>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

1.79.0 · source§

impl DivAssign<NonZero<u64>> for u64

source§

fn div_assign(&mut self, other: NonZero<u64>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

1.79.0 · source§

impl DivAssign<NonZero<u8>> for u8

source§

fn div_assign(&mut self, other: NonZero<u8>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

1.79.0 · source§

impl DivAssign<NonZero<usize>> for usize

source§

fn div_assign(&mut self, other: NonZero<usize>)

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

impl Encode for NonZero<i128>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<i16>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<i32>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<i64>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<i8>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<u128>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<u16>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<u32>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<u64>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl Encode for NonZero<u8>

§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
§

impl EncodeAsType for NonZero<i128>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<i16>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<i32>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<i64>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<i8>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<u128>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<u16>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<u32>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<u64>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
§

impl EncodeAsType for NonZero<u8>

§

fn encode_as_type_to<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, out: &mut Vec<u8>, ) -> Result<(), Error>
where R: TypeResolver,

Given some type_id, types, a context and some output target for the SCALE encoded bytes, attempt to SCALE encode the current value into the type given by type_id.
§

fn encode_as_type<R>( &self, type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Vec<u8>, Error>
where R: TypeResolver,

This is a helper function which internally calls [EncodeAsType::encode_as_type_to]. Prefer to implement that instead.
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<T> From<NonZero<T>> for T

source§

fn from(nonzero: NonZero<T>) -> T

Converts to this type from the input type.
1.41.0 · source§

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

source§

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

Converts NonZero<i16> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i16> to NonZero<i32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i16> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i16> to NonZero<isize> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i32> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i32> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i64> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i8> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i8> to NonZero<i16> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i8> to NonZero<i32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i8> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<i8> to NonZero<isize> losslessly.

§

impl From<NonZero<u128>> for NonZeroU256

§

fn from(value: NonZero<u128>) -> NonZeroU256

Converts to this type from the input type.
1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<i32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<u128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<u32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<u64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u16> to NonZero<usize> losslessly.

§

impl From<NonZero<u16>> for NonZeroU256

§

fn from(value: NonZero<u16>) -> NonZeroU256

Converts to this type from the input type.
source§

impl From<NonZero<u32>> for Error

source§

fn from(code: NonZero<u32>) -> Error

Converts to this type from the input type.
source§

impl From<NonZero<u32>> for Error

source§

fn from(code: NonZero<u32>) -> Error

Converts to this type from the input type.
source§

impl From<NonZero<u32>> for Error

source§

fn from(code: NonZero<u32>) -> Error

Converts to this type from the input type.
source§

impl From<NonZero<u32>> for Error

source§

fn from(code: NonZero<u32>) -> Error

Converts to this type from the input type.
1.41.0 · source§

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

source§

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

Converts NonZero<u32> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u32> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u32> to NonZero<u128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u32> to NonZero<u64> losslessly.

§

impl From<NonZero<u32>> for NonZeroU256

§

fn from(value: NonZero<u32>) -> NonZeroU256

Converts to this type from the input type.
1.41.0 · source§

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

source§

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

Converts NonZero<u64> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u64> to NonZero<u128> losslessly.

§

impl From<NonZero<u64>> for NonZeroU256

§

fn from(value: NonZero<u64>) -> NonZeroU256

Converts to this type from the input type.
1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<i128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<i16> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<i32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<i64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<isize> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<u128> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<u16> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<u32> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<u64> losslessly.

1.41.0 · source§

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

source§

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

Converts NonZero<u8> to NonZero<usize> losslessly.

§

impl From<NonZero<u8>> for NonZeroU256

§

fn from(value: NonZero<u8>) -> NonZeroU256

Converts to this type from the input type.
source§

impl FromFormattedStr for NonZero<u128>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<u128>, Error>
where F: Format,

source§

impl FromFormattedStr for NonZero<u16>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<u16>, Error>
where F: Format,

source§

impl FromFormattedStr for NonZero<u32>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<u32>, Error>
where F: Format,

source§

impl FromFormattedStr for NonZero<u64>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<u64>, Error>
where F: Format,

source§

impl FromFormattedStr for NonZero<u8>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<u8>, Error>
where F: Format,

source§

impl FromFormattedStr for NonZero<usize>

source§

fn from_formatted_str<F>(s: &str, format: &F) -> Result<NonZero<usize>, Error>
where F: Format,

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.28.0 · source§

impl<T> Hash for NonZero<T>

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
§

impl IntoVisitor for NonZero<i128>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<i128>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<i128> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<i16>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<i16>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<i16> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<i32>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<i32>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<i32> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<i64>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<i64>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<i64> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<i8>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<i8>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<i8> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<u128>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<u128>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<u128> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<u16>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<u16>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<u16> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<u32>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<u32>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<u32> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<u64>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<u64>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<u64> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
§

impl IntoVisitor for NonZero<u8>

§

type AnyVisitor<R: TypeResolver> = BasicVisitor<NonZero<u8>, R>

The visitor type used to decode SCALE encoded bytes to Self.
§

fn into_visitor<R>() -> <NonZero<u8> as IntoVisitor>::AnyVisitor<R>
where R: TypeResolver,

A means of obtaining this visitor.
1.28.0 · source§

impl<T> LowerHex for NonZero<T>

source§

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

Formats the value using the given formatter. Read more
§

impl MaxEncodedLen for NonZero<i128>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<i16>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<i32>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<i64>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<i8>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<u128>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<u16>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<u32>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<u64>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl MaxEncodedLen for NonZero<u8>

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
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.28.0 · source§

impl<T> Octal for NonZero<T>

source§

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

Formats the value using the given formatter. Read more
1.28.0 · source§

impl<T> Ord for NonZero<T>

source§

fn cmp(&self, other: &NonZero<T>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

fn max(self, other: NonZero<T>) -> NonZero<T>

Compares and returns the maximum of two values. Read more
source§

fn min(self, other: NonZero<T>) -> NonZero<T>

Compares and returns the minimum of two values. Read more
source§

fn clamp(self, min: NonZero<T>, max: NonZero<T>) -> NonZero<T>

Restrict a value to a certain interval. Read more
1.28.0 · source§

impl<T> PartialEq for NonZero<T>

source§

fn eq(&self, other: &NonZero<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &NonZero<T>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.28.0 · source§

impl<T> PartialOrd for NonZero<T>

source§

fn partial_cmp(&self, other: &NonZero<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
source§

fn lt(&self, other: &NonZero<T>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
source§

fn le(&self, other: &NonZero<T>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

fn gt(&self, other: &NonZero<T>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
source§

fn ge(&self, other: &NonZero<T>) -> bool

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.79.0 · source§

impl RemAssign<NonZero<u128>> for u128

source§

fn rem_assign(&mut self, other: NonZero<u128>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

1.79.0 · source§

impl RemAssign<NonZero<u16>> for u16

source§

fn rem_assign(&mut self, other: NonZero<u16>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

1.79.0 · source§

impl RemAssign<NonZero<u32>> for u32

source§

fn rem_assign(&mut self, other: NonZero<u32>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

1.79.0 · source§

impl RemAssign<NonZero<u64>> for u64

source§

fn rem_assign(&mut self, other: NonZero<u64>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

1.79.0 · source§

impl RemAssign<NonZero<u8>> for u8

source§

fn rem_assign(&mut self, other: NonZero<u8>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

1.79.0 · source§

impl RemAssign<NonZero<usize>> for usize

source§

fn rem_assign(&mut self, other: NonZero<usize>)

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

source§

impl Serialize for NonZero<i128>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<i16>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<i32>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<i64>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<i8>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<isize>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<u128>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<u16>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<u32>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<u64>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<u8>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Serialize for NonZero<usize>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
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 NonZero<i128> to NonZero<i16>.

§

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 NonZero<i128> to NonZero<i32>.

§

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 NonZero<i128> to NonZero<i64>.

§

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 NonZero<i128> to NonZero<i8>.

§

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 NonZero<i128> to NonZero<isize>.

§

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 NonZero<i128> to NonZero<u128>.

§

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 NonZero<i128> to NonZero<u16>.

§

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 NonZero<i128> to NonZero<u32>.

§

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 NonZero<i128> to NonZero<u64>.

§

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 NonZero<i128> to NonZero<u8>.

§

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 NonZero<i128> to NonZero<usize>.

§

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 NonZero<i16> to NonZero<i8>.

§

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 NonZero<i16> to NonZero<u128>.

§

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 NonZero<i16> to NonZero<u16>.

§

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 NonZero<i16> to NonZero<u32>.

§

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 NonZero<i16> to NonZero<u64>.

§

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 NonZero<i16> to NonZero<u8>.

§

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 NonZero<i16> to NonZero<usize>.

§

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 NonZero<i32> to NonZero<i16>.

§

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 NonZero<i32> to NonZero<i8>.

§

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 NonZero<i32> to NonZero<isize>.

§

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 NonZero<i32> to NonZero<u128>.

§

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 NonZero<i32> to NonZero<u16>.

§

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 NonZero<i32> to NonZero<u32>.

§

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 NonZero<i32> to NonZero<u64>.

§

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 NonZero<i32> to NonZero<u8>.

§

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 NonZero<i32> to NonZero<usize>.

§

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 NonZero<i64> to NonZero<i16>.

§

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 NonZero<i64> to NonZero<i32>.

§

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 NonZero<i64> to NonZero<i8>.

§

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 NonZero<i64> to NonZero<isize>.

§

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 NonZero<i64> to NonZero<u128>.

§

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 NonZero<i64> to NonZero<u16>.

§

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 NonZero<i64> to NonZero<u32>.

§

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 NonZero<i64> to NonZero<u64>.

§

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 NonZero<i64> to NonZero<u8>.

§

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 NonZero<i64> to NonZero<usize>.

§

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 NonZero<i8> to NonZero<u128>.

§

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 NonZero<i8> to NonZero<u16>.

§

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 NonZero<i8> to NonZero<u32>.

§

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 NonZero<i8> to NonZero<u64>.

§

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 NonZero<i8> to NonZero<u8>.

§

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 NonZero<i8> to NonZero<usize>.

§

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 NonZero<isize> to NonZero<i128>.

§

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 NonZero<isize> to NonZero<i16>.

§

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 NonZero<isize> to NonZero<i32>.

§

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 NonZero<isize> to NonZero<i64>.

§

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 NonZero<isize> to NonZero<i8>.

§

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 NonZero<isize> to NonZero<u128>.

§

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 NonZero<isize> to NonZero<u16>.

§

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 NonZero<isize> to NonZero<u32>.

§

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 NonZero<isize> to NonZero<u64>.

§

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 NonZero<isize> to NonZero<u8>.

§

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 NonZero<isize> to NonZero<usize>.

§

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 NonZero<u128> to NonZero<i128>.

§

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 NonZero<u128> to NonZero<i16>.

§

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 NonZero<u128> to NonZero<i32>.

§

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 NonZero<u128> to NonZero<i64>.

§

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 NonZero<u128> to NonZero<i8>.

§

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 NonZero<u128> to NonZero<isize>.

§

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 NonZero<u128> to NonZero<u16>.

§

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 NonZero<u128> to NonZero<u32>.

§

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 NonZero<u128> to NonZero<u64>.

§

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 NonZero<u128> to NonZero<u8>.

§

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 NonZero<u128> to NonZero<usize>.

§

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 NonZero<u16> to NonZero<i16>.

§

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 NonZero<u16> to NonZero<i8>.

§

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 NonZero<u16> to NonZero<isize>.

§

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 NonZero<u16> to NonZero<u8>.

§

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 NonZero<u32> to NonZero<i16>.

§

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 NonZero<u32> to NonZero<i32>.

§

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 NonZero<u32> to NonZero<i8>.

§

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 NonZero<u32> to NonZero<isize>.

§

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 NonZero<u32> to NonZero<u16>.

§

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 NonZero<u32> to NonZero<u8>.

§

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 NonZero<u32> to NonZero<usize>.

§

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 NonZero<u64> to NonZero<i16>.

§

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 NonZero<u64> to NonZero<i32>.

§

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 NonZero<u64> to NonZero<i64>.

§

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 NonZero<u64> to NonZero<i8>.

§

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 NonZero<u64> to NonZero<isize>.

§

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 NonZero<u64> to NonZero<u16>.

§

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 NonZero<u64> to NonZero<u32>.

§

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 NonZero<u64> to NonZero<u8>.

§

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 NonZero<u64> to NonZero<usize>.

§

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 NonZero<u8> to NonZero<i8>.

§

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 NonZero<usize> to NonZero<i128>.

§

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 NonZero<usize> to NonZero<i16>.

§

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 NonZero<usize> to NonZero<i32>.

§

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 NonZero<usize> to NonZero<i64>.

§

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 NonZero<usize> to NonZero<i8>.

§

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 NonZero<usize> to NonZero<isize>.

§

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 NonZero<usize> to NonZero<u128>.

§

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 NonZero<usize> to NonZero<u16>.

§

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 NonZero<usize> to NonZero<u32>.

§

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 NonZero<usize> to NonZero<u64>.

§

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 NonZero<usize> to NonZero<u8>.

§

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 NonZero<i128>.

§

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 NonZero<i16>.

§

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 NonZero<i32>.

§

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 NonZero<i64>.

§

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 NonZero<i8>.

§

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 NonZero<isize>.

§

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 NonZero<u128>.

§

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 NonZero<u16>.

§

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 NonZero<u32>.

§

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 NonZero<u64>.

§

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 NonZero<u8>.

§

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 NonZero<usize>.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
§

impl TypeInfo for NonZero<i128>

§

type Identity = NonZero<i128>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<i16>

§

type Identity = NonZero<i16>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<i32>

§

type Identity = NonZero<i32>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<i64>

§

type Identity = NonZero<i64>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<i8>

§

type Identity = NonZero<i8>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<u128>

§

type Identity = NonZero<u128>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<u16>

§

type Identity = NonZero<u16>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<u32>

§

type Identity = NonZero<u32>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<u64>

§

type Identity = NonZero<u64>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl TypeInfo for NonZero<u8>

§

type Identity = NonZero<u8>

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
1.28.0 · source§

impl<T> UpperHex for NonZero<T>

source§

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

Formats the value using the given formatter. Read more
§

impl Value for NonZero<i128>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<i16>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<i32>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<i64>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<i8>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<isize>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<u128>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<u16>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<u32>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<u64>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<u8>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Value for NonZero<usize>

§

fn record(&self, key: &Field, visitor: &mut dyn Visit)

Visits this value with the given Visitor.
§

impl Zeroize for NonZero<i128>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<i16>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<i32>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<i64>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<i8>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<isize>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<u128>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<u16>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<u32>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<u64>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<u8>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl Zeroize for NonZero<usize>

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
§

impl ConstEncodedLen for NonZero<i128>

§

impl ConstEncodedLen for NonZero<i16>

§

impl ConstEncodedLen for NonZero<i32>

§

impl ConstEncodedLen for NonZero<i64>

§

impl ConstEncodedLen for NonZero<i8>

§

impl ConstEncodedLen for NonZero<u128>

§

impl ConstEncodedLen for NonZero<u16>

§

impl ConstEncodedLen for NonZero<u32>

§

impl ConstEncodedLen for NonZero<u64>

§

impl ConstEncodedLen for NonZero<u8>

1.28.0 · source§

impl<T> Copy for NonZero<T>

§

impl EncodeLike for NonZero<i128>

§

impl EncodeLike for NonZero<i16>

§

impl EncodeLike for NonZero<i32>

§

impl EncodeLike for NonZero<i64>

§

impl EncodeLike for NonZero<i8>

§

impl EncodeLike for NonZero<u128>

§

impl EncodeLike for NonZero<u16>

§

impl EncodeLike for NonZero<u32>

§

impl EncodeLike for NonZero<u64>

§

impl EncodeLike for NonZero<u8>

1.28.0 · source§

impl<T> Eq for NonZero<T>
where T: ZeroablePrimitive + Eq,

1.28.0 · source§

impl<T> Freeze for NonZero<T>

1.28.0 · source§

impl<T> RefUnwindSafe for NonZero<T>

1.28.0 · source§

impl<T> Send for NonZero<T>

source§

impl<T> StructuralPartialEq for NonZero<T>

1.28.0 · source§

impl<T> Sync for NonZero<T>

source§

impl ToFormattedStr for NonZero<u128>

source§

impl ToFormattedStr for NonZero<u16>

source§

impl ToFormattedStr for NonZero<u32>

source§

impl ToFormattedStr for NonZero<u64>

source§

impl ToFormattedStr for NonZero<u8>

source§

impl ToFormattedStr for NonZero<usize>

§

impl Unaligned for NonZero<i8>

§

impl Unaligned for NonZero<u8>

1.28.0 · source§

impl<T> Unpin for NonZero<T>

1.28.0 · source§

impl<T> UnwindSafe for NonZero<T>

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
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

§

impl<T> CheckedConversion for T

§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> DecodeAll for T
where T: Decode,

§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

impl<T> DecodeAsType for T
where T: IntoVisitor,

§

fn decode_as_type_maybe_compact<R>( input: &mut &[u8], type_id: <R as TypeResolver>::TypeId, types: &R, is_compact: bool, ) -> Result<T, Error>
where R: TypeResolver,

§

fn decode_as_type<R>( input: &mut &[u8], type_id: <R as TypeResolver>::TypeId, types: &R, ) -> Result<Self, Error>
where R: TypeResolver,

Given some input bytes, a type_id, and type registry, attempt to decode said bytes into Self. Implementations should modify the &mut reference to the bytes such that any bytes not used in the course of decoding are still pointed to after decoding is complete.
§

impl<T> DecodeLimit for T
where T: Decode,

§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8], ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
§

impl<T> DecodeWithMetadata for T
where T: DecodeAsType,

§

fn decode_with_metadata( bytes: &mut &[u8], type_id: u32, metadata: &Metadata, ) -> Result<T, Error>

Given some metadata and a type ID, attempt to SCALE decode the provided bytes into Self.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<T> EncodeWithMetadata for T
where T: EncodeAsType,

§

fn encode_with_metadata( &self, type_id: u32, metadata: &Metadata, bytes: &mut Vec<u8>, ) -> Result<(), Error>

SCALE encode this type to bytes, possibly with the help of metadata.

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromBits<T> for T

§

fn from_bits(other: T) -> T

Convert other to Self, preserving bitwise representation
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

impl<T> KeyedVec for T
where T: Codec,

§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T> SaturatedConversion for T

§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
source§

impl<T> ToFormattedString for T
where T: ToFormattedStr,

source§

fn read_to_fmt_writer<F, W>(&self, w: W, format: &F) -> Result<usize, Error>
where F: Format, W: Write,

source§

fn read_to_io_writer<F, W>(&self, w: W, format: &F) -> Result<usize, Error>
where F: Format, W: Write,

source§

fn to_formatted_string<F>(&self, format: &F) -> String
where F: Format,

Returns a string representation of the number formatted according to the provided format.
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
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<S> Codec for S
where S: Decode + Encode,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> EncodeLike<&&T> for T
where T: Encode,

§

impl<T> EncodeLike<&T> for T
where T: Encode,

§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

§

impl<'a, T> EncodeLike<Cow<'a, T>> for T
where T: ToOwned + Encode,

§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

§

impl<T> Error for T
where T: 'static + Debug + Display + Send + Sync,

§

impl<S> FullCodec for S
where S: Decode + FullEncode,

§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

§

impl<T> JsonSchemaMaybe for T

§

impl<T> MaybeDebug for T
where T: Debug,

§

impl<T> MaybeDisplay for T
where T: Display,

§

impl<T> MaybeFromStr for T
where T: FromStr,

§

impl<T> MaybeHash for T
where T: Hash,

§

impl<T> MaybeHash for T
where T: Hash,

§

impl<T> MaybeRefUnwindSafe for T
where T: RefUnwindSafe,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSerialize for T
where T: Serialize,

§

impl<T> MaybeSerializeDeserialize for T

§

impl<T> Member for T
where T: Send + Sync + Debug + Eq + PartialEq + Clone + 'static,

§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,