Struct devela::_std::num::NonZeroUsize

1.28.0 · source ·
pub struct NonZeroUsize(/* private fields */);
Expand description

An integer that is known not to equal zero.

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

use std::mem::size_of;
assert_eq!(size_of::<Option<core::num::NonZeroUsize>>(), size_of::<usize>());

Layout

NonZeroUsize is guaranteed to have the same layout and bit validity as usize with the exception that 0 is not a valid instance. Option<NonZeroUsize> is guaranteed to be compatible with usize, including in FFI.

Thanks to the null pointer optimization, NonZeroUsize and Option<NonZeroUsize> are guaranteed to have the same size and alignment:

use std::num::NonZeroUsize;

assert_eq!(size_of::<NonZeroUsize>(), size_of::<Option<NonZeroUsize>>());
assert_eq!(align_of::<NonZeroUsize>(), align_of::<Option<NonZeroUsize>>());

Implementations§

source§

impl NonZeroUsize

const: 1.28.0 · source

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

Available on crate feature num only.

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.

const: 1.47.0 · source

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

Available on crate feature num only.

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

const: 1.34.0 · source

pub const fn get(self) -> usize

Available on crate feature num only.

Returns the value as a primitive type.

source§

impl NonZeroUsize

1.53.0 (const: 1.53.0) · source

pub const fn leading_zeros(self) -> u32

Available on crate feature num only.

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

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

Examples

Basic usage:

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

assert_eq!(n.leading_zeros(), 0);
1.53.0 (const: 1.53.0) · source

pub const fn trailing_zeros(self) -> u32

Available on crate feature num only.

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

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

Examples

Basic usage:

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

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

impl NonZeroUsize

1.64.0 (const: 1.64.0) · source

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

Available on crate feature num only.

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

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

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

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

Available on crate feature num only.

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

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

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

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

🔬This is a nightly-only experimental API. (nonzero_ops)
Available on crate feature num only.

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

Examples
#![feature(nonzero_ops)]

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

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

pub const fn checked_next_power_of_two(self) -> Option<NonZeroUsize>

Available on crate feature num only.

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

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

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

pub const fn ilog2(self) -> u32

Available on crate feature num only.

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

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

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

pub const fn ilog10(self) -> u32

Available on crate feature num only.

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

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

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

pub fn midpoint(self, rhs: NonZeroUsize) -> NonZeroUsize

🔬This is a nightly-only experimental API. (num_midpoint)
Available on crate feature num only.

Calculates the middle point of self and rhs.

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

Examples
#![feature(num_midpoint)]

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

assert_eq!(one.midpoint(four), two);
assert_eq!(four.midpoint(one), two);
source§

impl NonZeroUsize

1.64.0 (const: 1.64.0) · source

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

Available on crate feature num only.

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

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

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

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

Available on crate feature num only.

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

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

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

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

🔬This is a nightly-only experimental API. (nonzero_ops)
Available on crate feature num only.

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

Examples
#![feature(nonzero_ops)]

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

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

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

Available on crate feature num only.

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

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

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

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

Available on crate feature num only.

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

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

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

impl NonZeroUsize

1.59.0 (const: 1.59.0) · source

pub const fn is_power_of_two(self) -> bool

Available on crate feature num only.

Returns true if and only if self == (1 << k) for some k.

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

Examples

Basic usage:

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

impl NonZeroUsize

1.70.0 · source

pub const MIN: NonZeroUsize = _

Available on crate feature num only.

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

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

pub const MAX: NonZeroUsize = _

Available on crate feature num only.

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

Examples
assert_eq!(NonZeroUsize::MAX.get(), usize::MAX);
source§

impl NonZeroUsize

1.67.0 · source

pub const BITS: u32 = 64u32

Available on crate feature num only.

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

This value is equal to usize::BITS.

Examples

assert_eq!(NonZeroUsize::BITS, usize::BITS);

Trait Implementations§

§

impl AsBytes for NonZeroUsize

§

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
source§

impl Binary for NonZeroUsize

source§

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

Formats the value using the given formatter.
1.45.0 · source§

impl BitOr<NonZeroUsize> for usize

§

type Output = NonZeroUsize

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZeroUsize) -> <usize as BitOr<NonZeroUsize>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr<usize> for NonZeroUsize

§

type Output = NonZeroUsize

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: usize) -> <NonZeroUsize as BitOr<usize>>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOr for NonZeroUsize

§

type Output = NonZeroUsize

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: NonZeroUsize) -> <NonZeroUsize as BitOr>::Output

Performs the | operation. Read more
1.45.0 · source§

impl BitOrAssign<usize> for NonZeroUsize

source§

fn bitor_assign(&mut self, rhs: usize)

Performs the |= operation. Read more
1.45.0 · source§

impl BitOrAssign for NonZeroUsize

source§

fn bitor_assign(&mut self, rhs: NonZeroUsize)

Performs the |= operation. Read more
source§

impl BitSize<64> for NonZeroUsize

Available on crate feature mem only.
source§

const BIT_SIZE: usize = _

The bit size of this type (only the relevant data part, without padding). Read more
source§

const MIN_BYTE_SIZE: usize = _

The rounded up byte size for this type. Read more
source§

fn bit_size(&self) -> usize

Returns the bit size of this type (only the relevant data part, without padding). Read more
source§

fn min_byte_size(&self) -> usize

Returns the rounded up byte size for this type. Read more
§

impl CheckedBitPattern for NonZeroUsize

§

type Bits = usize

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern( bits: &<NonZeroUsize as CheckedBitPattern>::Bits ) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl Clone for NonZeroUsize

source§

fn clone(&self) -> NonZeroUsize

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
§

impl Contiguous for NonZeroUsize

§

type Int = usize

The primitive integer type with an identical representation to this type. Read more
§

const MAX_VALUE: usize = 18_446_744_073_709_551_615usize

The upper inclusive bound for valid instances of this type.
§

const MIN_VALUE: usize = 1usize

The lower inclusive bound for valid instances of this type.
§

fn from_integer(value: Self::Int) -> Option<Self>

If value is within the range for valid instances of this type, returns Some(converted_value), otherwise, returns None. Read more
§

fn into_integer(self) -> Self::Int

Perform the conversion from C into the underlying integral type. This mostly exists otherwise generic code would need unsafe for the value as integer Read more
source§

impl Debug for NonZeroUsize

source§

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

Formats the value using the given formatter. Read more
source§

impl Display for NonZeroUsize

source§

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

Formats the value using the given formatter. Read more
1.51.0 · source§

impl Div<NonZeroUsize> for usize

source§

fn div(self, other: NonZeroUsize) -> usize

This operation rounds towards zero, truncating any fractional part of the exact result, and cannot panic.

§

type Output = usize

The resulting type after applying the / operator.
source§

impl From<Alignment> for NonZeroUsize

source§

fn from(align: Alignment) -> NonZeroUsize

Converts to this type from the input type.
1.41.0 · source§

impl From<NonZeroU16> for NonZeroUsize

source§

fn from(small: NonZeroU16) -> NonZeroUsize

Converts NonZeroU16 to NonZeroUsize losslessly.

1.41.0 · source§

impl From<NonZeroU8> for NonZeroUsize

source§

fn from(small: NonZeroU8) -> NonZeroUsize

Converts NonZeroU8 to NonZeroUsize losslessly.

1.31.0 · source§

impl From<NonZeroUsize> for usize

source§

fn from(nonzero: NonZeroUsize) -> usize

Converts a NonZeroUsize into an usize

1.35.0 · source§

impl FromStr for NonZeroUsize

§

type Err = ParseIntError

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

fn from_str(src: &str) -> Result<NonZeroUsize, <NonZeroUsize as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for NonZeroUsize

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
source§

impl LowerHex for NonZeroUsize

source§

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

Formats the value using the given formatter.
source§

impl Num for NonZeroUsize

Available on crate feature num only.
§

type Inner = usize

The internal representation of this numeric type.
§

type OpOut = NonZeroUsize

The output type for operations.
§

type OpRhs = NonZeroUsize

The right hand side type for operations.
source§

fn num_into(self) -> Self::Inner

Returns the inner self representation.
source§

fn num_from(from: Self::Inner) -> Result<Self>

Returns Self if given a valid value.
source§

fn num_from_ref(from: &Self::Inner) -> Result<Self>

Returns Self if given a valid &value.
source§

fn num_set(&mut self, value: Self::Inner) -> Result<()>

Sets self to the given valid value.
source§

fn num_set_ref(&mut self, value: &Self::Inner) -> Result<()>

Sets self to the given valid &value.
source§

fn num_is_zero(&self) -> Result<bool>

Returns true if self is zero.
source§

fn num_is_one(&self) -> Result<bool>

Returns true if self is one.
source§

fn num_get_zero() -> Result<Self>

Returns the number zero.
source§

fn num_get_one() -> Result<Self>

Returns the number one.
source§

fn num_set_zero(&mut self) -> Result<()>

Sets self to 0.
source§

fn num_set_one(&mut self) -> Result<()>

Sets the number to one.
source§

fn num_mul(self, other: Self) -> Result<Self::OpOut>

Computes self * other.
source§

fn num_mul_ref(self, other: &Self) -> Result<Self::OpOut>

Computes self * &other.
source§

fn num_ref_mul(&self, other: Self) -> Result<Self::OpOut>

Computes &self * other.
source§

fn num_ref_mul_ref(&self, other: &Self) -> Result<Self::OpOut>

Computes &self * &other.
source§

fn num_add(self, other: Self) -> Result<Self::OpOut>

Computes self + other.
source§

fn num_add_ref(self, other: &Self) -> Result<Self::OpOut>

Computes self + &other.
source§

fn num_ref_add(&self, other: Self) -> Result<Self::OpOut>

Computes &self + other.
source§

fn num_ref_add_ref(&self, other: &Self) -> Result<Self::OpOut>

Computes &self + &other.
source§

fn num_sub(self, other: Self) -> Result<Self::OpOut>

Computes self - other.
source§

fn num_sub_ref(self, other: &Self) -> Result<Self::OpOut>

Computes self - &other.
source§

fn num_ref_sub(&self, other: Self) -> Result<Self::OpOut>

Computes &self - other.
source§

fn num_ref_sub_ref(&self, other: &Self) -> Result<Self::OpOut>

Computes &self - &other.
source§

fn num_div(self, other: Self) -> Result<Self::OpOut>

Computes self / other.
source§

fn num_div_ref(self, other: &Self) -> Result<Self::OpOut>

Computes self / &other.
source§

fn num_ref_div(&self, other: Self) -> Result<Self::OpOut>

Computes &self / other.
source§

fn num_ref_div_ref(&self, other: &Self) -> Result<Self::OpOut>

Computes &self / &other.
source§

fn num_rem(self, other: Self) -> Result<Self::OpOut>

Computes self % other.
source§

fn num_rem_ref(self, other: &Self) -> Result<Self::OpOut>

Computes self % &other.
source§

fn num_ref_rem(&self, other: Self) -> Result<Self::OpOut>

Computes &self % other.
source§

fn num_ref_rem_ref(&self, other: &Self) -> Result<Self::OpOut>

Computes &self % &other.
source§

fn num_neg(self) -> Result<Self::OpOut>

Computes - self.
source§

fn num_ref_neg(&self) -> Result<Self::OpOut>

Computes - &self.
source§

fn num_abs(self) -> Result<Self>

Computes the absolute value of self.
source§

fn num_ref_abs(&self) -> Result<Self>

Computes the absolute value of &self.
source§

impl Octal for NonZeroUsize

source§

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

Formats the value using the given formatter.
source§

impl Ord for NonZeroUsize

source§

fn cmp(&self, other: &NonZeroUsize) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for NonZeroUsize

source§

fn eq(&self, other: &NonZeroUsize) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for NonZeroUsize

source§

fn partial_cmp(&self, other: &NonZeroUsize) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
1.51.0 · source§

impl Rem<NonZeroUsize> for usize

source§

fn rem(self, other: NonZeroUsize) -> usize

This operation satisfies n % d == n - (n / d) * d, and cannot panic.

§

type Output = usize

The resulting type after applying the % operator.
1.49.0 · source§

impl TryFrom<NonZeroI128> for NonZeroUsize

source§

fn try_from( value: NonZeroI128 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroI128>>::Error>

Attempts to convert NonZeroI128 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroI16> for NonZeroUsize

source§

fn try_from( value: NonZeroI16 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroI16>>::Error>

Attempts to convert NonZeroI16 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroI32> for NonZeroUsize

source§

fn try_from( value: NonZeroI32 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroI32>>::Error>

Attempts to convert NonZeroI32 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroI64> for NonZeroUsize

source§

fn try_from( value: NonZeroI64 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroI64>>::Error>

Attempts to convert NonZeroI64 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroI8> for NonZeroUsize

source§

fn try_from( value: NonZeroI8 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroI8>>::Error>

Attempts to convert NonZeroI8 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroIsize> for NonZeroUsize

source§

fn try_from( value: NonZeroIsize ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroIsize>>::Error>

Attempts to convert NonZeroIsize to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroU128> for NonZeroUsize

source§

fn try_from( value: NonZeroU128 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroU128>>::Error>

Attempts to convert NonZeroU128 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroU32> for NonZeroUsize

source§

fn try_from( value: NonZeroU32 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroU32>>::Error>

Attempts to convert NonZeroU32 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroU64> for NonZeroUsize

source§

fn try_from( value: NonZeroU64 ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<NonZeroU64>>::Error>

Attempts to convert NonZeroU64 to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

impl TryFrom<NonZeroUsize> for Alignment

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

fn try_from( align: NonZeroUsize ) -> Result<Alignment, <Alignment as TryFrom<NonZeroUsize>>::Error>

Performs the conversion.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroI128

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroI128, <NonZeroI128 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroI128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroI16

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroI16, <NonZeroI16 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroI16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroI32

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroI32, <NonZeroI32 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroI32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroI64

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroI64, <NonZeroI64 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroI64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroI8

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroI8, <NonZeroI8 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroI8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroIsize

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroIsize, <NonZeroIsize as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroIsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroU128

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroU128, <NonZeroU128 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroU128.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroU16

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroU16, <NonZeroU16 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroU16.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroU32

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroU32, <NonZeroU32 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroU32.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroU64

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroU64, <NonZeroU64 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroU64.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.49.0 · source§

impl TryFrom<NonZeroUsize> for NonZeroU8

source§

fn try_from( value: NonZeroUsize ) -> Result<NonZeroU8, <NonZeroU8 as TryFrom<NonZeroUsize>>::Error>

Attempts to convert NonZeroUsize to NonZeroU8.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
1.46.0 · source§

impl TryFrom<usize> for NonZeroUsize

source§

fn try_from( value: usize ) -> Result<NonZeroUsize, <NonZeroUsize as TryFrom<usize>>::Error>

Attempts to convert usize to NonZeroUsize.

§

type Error = TryFromIntError

The type returned in the event of a conversion error.
source§

impl UpperHex for NonZeroUsize

source§

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

Formats the value using the given formatter.
source§

impl Copy for NonZeroUsize

source§

impl Eq for NonZeroUsize

source§

impl IntBufAble for NonZeroUsize

Available on crate features unsafe_text and text only.
§

impl NoUninit for NonZeroUsize

§

impl PodInOption for NonZeroUsize

source§

impl StructuralEq for NonZeroUsize

source§

impl StructuralPartialEq for NonZeroUsize

§

impl ZeroableInOption for NonZeroUsize

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Also for T

source§

fn also_mut<F: FnOnce(&mut Self)>(self, f: F) -> Self

Available on crate feature result only.
Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
source§

fn also_ref<F: FnOnce(&Self)>(self, f: F) -> Self

Available on crate feature result only.
Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AnyExt for Twhere T: Any,

source§

fn type_of(&self) -> TypeId

Available on crate feature any only.
Returns the TypeId of self. Read more
source§

fn type_name(&self) -> &'static str

Available on crate feature any only.
Returns the type name of self. Read more
source§

fn type_is<T: 'static>(&self) -> bool

Available on crate feature any only.
Returns true if Self is of type T. Read more
source§

fn as_any_ref(&self) -> &dyn Anywhere Self: Sized,

Available on crate feature any only.
Upcasts &self as &dyn Any. Read more
source§

fn as_any_mut(&mut self) -> &mut dyn Anywhere Self: Sized,

Available on crate feature any only.
Upcasts &mut self as &mut dyn Any. Read more
source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>where Self: Sized,

Available on crate feature any only.
Upcasts Box<self> as Box<dyn Any>. Read more
source§

impl<T, Res> Apply<Res> for Twhere T: ?Sized,

source§

fn apply<F: FnOnce(Self) -> Res>(self, f: F) -> Reswhere Self: Sized,

Available on crate feature result only.
Apply a function which takes the parameter by value.
source§

fn apply_ref<F: FnOnce(&Self) -> Res>(&self, f: F) -> Res

Available on crate feature result only.
Apply a function which takes the parameter by shared reference.
source§

fn apply_mut<F: FnOnce(&mut Self) -> Res>(&mut self, f: F) -> Res

Available on crate feature result only.
Apply a function which takes the parameter by exclusive reference.
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<Q, K> Equivalent<K> for Qwhere 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Mem for Twhere T: ?Sized,

source§

const NEEDS_DROP: bool = _

Available on crate feature mem only.
Whether dropping values of this type matters.
source§

fn mem_needs_drop(&self) -> bool

Available on crate feature mem only.
Returns true if dropping values of this type matters.
source§

fn mem_drop(self)where Self: Sized,

Available on crate feature mem only.
Drops self by running its destructor.
source§

fn mem_forget(self)where Self: Sized,

Available on crate feature mem only.
Forgets about self without running its destructor.
source§

fn mem_replace(&mut self, other: Self) -> Selfwhere Self: Sized,

Available on crate feature mem only.
Replaces self with other, returning the previous value of self.
source§

fn mem_take(&mut self) -> Selfwhere Self: Default,

Available on crate feature mem only.
Replaces self with its default value, returning the previous value of self.
source§

fn mem_swap(&mut self, other: &mut Self)where Self: Sized,

Available on crate feature mem only.
Swaps the value of self and other without deinitializing either one.
source§

fn mem_as_bytes(&self) -> &[u8] where Self: Sync + Unpin,

Available on crate features mem and unsafe_mem only.
View a Sync + Unpin self as &[u8]. Read more
source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8] where Self: Sync + Unpin,

Available on crate features mem and unsafe_mem only.
View a Sync + Unpin self as &mut [u8].
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> Size for T

source§

const BYTE_ALIGN: usize = _

Available on crate feature mem only.
The alignment of this type in bytes.
source§

const BYTE_SIZE: usize = _

Available on crate feature mem only.
The size of this type in bytes.
source§

const PTR_SIZE: usize = 8usize

Available on crate feature mem only.
The size of a pointer in bytes, for the current platform.
source§

fn byte_align(&self) -> usize

Available on crate feature mem only.
Returns the alignment of this type in bytes.
source§

fn byte_size(&self) -> usize

Available on crate feature mem only.
Returns the size of this type in bytes. Read more
source§

fn ptr_ratio(&self) -> (usize, usize)

Available on crate feature mem only.
Returns the size ratio between PTR_SIZE and BYTE_SIZE. Read more
source§

impl<T> ToOwned for Twhere 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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.