|= operation. Read more|= operation. Read moreCreates a non-zero if the given value is not zero.
\nCreates a non-zero without checking whether the value is non-zero.\nThis results in undefined behavior if the value is zero.
\nThe value must not be zero.
\nnonzero_from_mut #106290)Converts a reference to a non-zero mutable reference\nif the referenced value is not zero.
\nnonzero_from_mut #106290)Converts a mutable reference to a non-zero mutable reference\nwithout checking whether the referenced value is non-zero.\nThis results in undefined behavior if the referenced value is zero.
\nThe referenced value must not be zero.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self,\nwith overflow information, see\ni128::overflowing_abs.
Saturating absolute value, see\ni128::saturating_abs.
let pos = NonZero::new(1i128)?;\nlet neg = NonZero::new(-1i128)?;\nlet min = NonZero::new(i128::MIN)?;\nlet min_plus = NonZero::new(i128::MIN + 1)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\ni128::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1u128)?;\nlet i_pos = NonZero::new(1i128)?;\nlet i_neg = NonZero::new(-1i128)?;\nlet i_min = NonZero::new(i128::MIN)?;\nlet u_max = NonZero::new(u128::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<i128>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee i128::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<i128>::MAX\nif self == NonZero::<i128>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5i128)?;\nlet neg_five = NonZero::new(-5i128)?;\nlet min = NonZero::new(i128::MIN)?;\nlet min_plus_one = NonZero::new(i128::MIN + 1)?;\nlet max = NonZero::new(i128::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See i128::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<i128>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i128::MAX, or self * rhs < i128::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<i128>::MIN or NonZero::<i128>::MAX on overflow.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self,\nwith overflow information, see\ni16::overflowing_abs.
Saturating absolute value, see\ni16::saturating_abs.
let pos = NonZero::new(1i16)?;\nlet neg = NonZero::new(-1i16)?;\nlet min = NonZero::new(i16::MIN)?;\nlet min_plus = NonZero::new(i16::MIN + 1)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\ni16::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1u16)?;\nlet i_pos = NonZero::new(1i16)?;\nlet i_neg = NonZero::new(-1i16)?;\nlet i_min = NonZero::new(i16::MIN)?;\nlet u_max = NonZero::new(u16::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<i16>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee i16::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<i16>::MAX\nif self == NonZero::<i16>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5i16)?;\nlet neg_five = NonZero::new(-5i16)?;\nlet min = NonZero::new(i16::MIN)?;\nlet min_plus_one = NonZero::new(i16::MIN + 1)?;\nlet max = NonZero::new(i16::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See i16::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<i16>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i16::MAX, or self * rhs < i16::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<i16>::MIN or NonZero::<i16>::MAX on overflow.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self,\nwith overflow information, see\ni32::overflowing_abs.
Saturating absolute value, see\ni32::saturating_abs.
let pos = NonZero::new(1i32)?;\nlet neg = NonZero::new(-1i32)?;\nlet min = NonZero::new(i32::MIN)?;\nlet min_plus = NonZero::new(i32::MIN + 1)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\ni32::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1u32)?;\nlet i_pos = NonZero::new(1i32)?;\nlet i_neg = NonZero::new(-1i32)?;\nlet i_min = NonZero::new(i32::MIN)?;\nlet u_max = NonZero::new(u32::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<i32>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee i32::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<i32>::MAX\nif self == NonZero::<i32>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5i32)?;\nlet neg_five = NonZero::new(-5i32)?;\nlet min = NonZero::new(i32::MIN)?;\nlet min_plus_one = NonZero::new(i32::MIN + 1)?;\nlet max = NonZero::new(i32::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See i32::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<i32>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i32::MAX, or self * rhs < i32::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<i32>::MIN or NonZero::<i32>::MAX on overflow.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self,\nwith overflow information, see\ni64::overflowing_abs.
Saturating absolute value, see\ni64::saturating_abs.
let pos = NonZero::new(1i64)?;\nlet neg = NonZero::new(-1i64)?;\nlet min = NonZero::new(i64::MIN)?;\nlet min_plus = NonZero::new(i64::MIN + 1)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\ni64::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1u64)?;\nlet i_pos = NonZero::new(1i64)?;\nlet i_neg = NonZero::new(-1i64)?;\nlet i_min = NonZero::new(i64::MIN)?;\nlet u_max = NonZero::new(u64::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<i64>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee i64::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<i64>::MAX\nif self == NonZero::<i64>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5i64)?;\nlet neg_five = NonZero::new(-5i64)?;\nlet min = NonZero::new(i64::MIN)?;\nlet min_plus_one = NonZero::new(i64::MIN + 1)?;\nlet max = NonZero::new(i64::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See i64::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<i64>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i64::MAX, or self * rhs < i64::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<i64>::MIN or NonZero::<i64>::MAX on overflow.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self,\nwith overflow information, see\ni8::overflowing_abs.
Saturating absolute value, see\ni8::saturating_abs.
let pos = NonZero::new(1i8)?;\nlet neg = NonZero::new(-1i8)?;\nlet min = NonZero::new(i8::MIN)?;\nlet min_plus = NonZero::new(i8::MIN + 1)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\ni8::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1u8)?;\nlet i_pos = NonZero::new(1i8)?;\nlet i_neg = NonZero::new(-1i8)?;\nlet i_min = NonZero::new(i8::MIN)?;\nlet u_max = NonZero::new(u8::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<i8>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee i8::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<i8>::MAX\nif self == NonZero::<i8>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5i8)?;\nlet neg_five = NonZero::new(-5i8)?;\nlet min = NonZero::new(i8::MIN)?;\nlet min_plus_one = NonZero::new(i8::MIN + 1)?;\nlet max = NonZero::new(i8::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See i8::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<i8>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > i8::MAX, or self * rhs < i8::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<i8>::MIN or NonZero::<i8>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type,\nequal to isize::MIN.
Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.
The largest value that can be represented by this non-zero\ninteger type,\nequal to isize::MAX.
Note: While most integer types are defined for every whole\nnumber between MIN and MAX, signed non-zero integers are\na special case. They have a “gap” at 0.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nComputes the absolute value of self.\nSee isize::abs\nfor documentation on overflow behavior.
Computes the absolute value of self,\nwith overflow information, see\nisize::overflowing_abs.
Saturating absolute value, see\nisize::saturating_abs.
let pos = NonZero::new(1isize)?;\nlet neg = NonZero::new(-1isize)?;\nlet min = NonZero::new(isize::MIN)?;\nlet min_plus = NonZero::new(isize::MIN + 1)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(pos, pos.saturating_abs());\nassert_eq!(pos, neg.saturating_abs());\nassert_eq!(max, min.saturating_abs());\nassert_eq!(max, min_plus.saturating_abs());Wrapping absolute value, see\nisize::wrapping_abs.
Computes the absolute value of self\nwithout any wrapping or panicking.
\nlet u_pos = NonZero::new(1usize)?;\nlet i_pos = NonZero::new(1isize)?;\nlet i_neg = NonZero::new(-1isize)?;\nlet i_min = NonZero::new(isize::MIN)?;\nlet u_max = NonZero::new(usize::MAX / 2 + 1)?;\n\nassert_eq!(u_pos, i_pos.unsigned_abs());\nassert_eq!(u_pos, i_neg.unsigned_abs());\nassert_eq!(u_max, i_min.unsigned_abs());Returns true if self is positive and false if the\nnumber is negative.
Returns true if self is negative and false if the\nnumber is positive.
Checked negation. Computes -self,\nreturning None if self == NonZero::<isize>::MIN.
Negates self, overflowing if this is equal to the minimum value.
\nSee isize::overflowing_neg\nfor documentation on overflow behavior.
Saturating negation. Computes -self,\nreturning NonZero::<isize>::MAX\nif self == NonZero::<isize>::MIN\ninstead of overflowing.
let pos_five = NonZero::new(5isize)?;\nlet neg_five = NonZero::new(-5isize)?;\nlet min = NonZero::new(isize::MIN)?;\nlet min_plus_one = NonZero::new(isize::MIN + 1)?;\nlet max = NonZero::new(isize::MAX)?;\n\nassert_eq!(pos_five.saturating_neg(), neg_five);\nassert_eq!(min.saturating_neg(), max);\nassert_eq!(max.saturating_neg(), min_plus_one);Wrapping (modular) negation. Computes -self, wrapping around at the boundary\nof the type.
See isize::wrapping_neg\nfor documentation on overflow behavior.
Returns the bit pattern of self reinterpreted as an unsigned integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<isize>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > isize::MAX, or self * rhs < isize::MIN.
Raise non-zero value to an integer power.\nReturn NonZero::<isize>::MIN or NonZero::<isize>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<u128>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u128::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2u128)?;\nlet three = NonZero::new(3u128)?;\nlet four = NonZero::new(4u128)?;\nlet max = NonZero::new(u128::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 2 logarithm of the number, rounded down.
\nThis is the same operation as\nu128::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nu128::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<u128>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u128::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<u128>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<u16>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u16::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2u16)?;\nlet three = NonZero::new(3u16)?;\nlet four = NonZero::new(4u16)?;\nlet max = NonZero::new(u16::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 2 logarithm of the number, rounded down.
\nThis is the same operation as\nu16::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nu16::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<u16>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u16::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<u16>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<u32>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u32::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2u32)?;\nlet three = NonZero::new(3u32)?;\nlet four = NonZero::new(4u32)?;\nlet max = NonZero::new(u32::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 2 logarithm of the number, rounded down.
\nThis is the same operation as\nu32::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nu32::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<u32>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u32::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<u32>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<u64>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u64::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2u64)?;\nlet three = NonZero::new(3u64)?;\nlet four = NonZero::new(4u64)?;\nlet max = NonZero::new(u64::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 2 logarithm of the number, rounded down.
\nThis is the same operation as\nu64::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nu64::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<u64>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u64::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<u64>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nReturns 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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<u8>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > u8::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2u8)?;\nlet three = NonZero::new(3u8)?;\nlet four = NonZero::new(4u8)?;\nlet max = NonZero::new(u8::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nu8::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<u8>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > u8::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<u8>::MAX on overflow.
The smallest value that can be represented by this non-zero\ninteger type, 1.
\nThe largest value that can be represented by this non-zero\ninteger type,\nequal to usize::MAX.
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.
Returns the number of trailing zeros in the binary representation\nof 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.
isolate_most_least_significant_one #136909)Returns self with only the most significant bit set.
isolate_most_least_significant_one #136909)Returns self with only the least significant bit set.
Returns the number of ones in the binary representation of self.
nonzero_bitwise #128281)Shifts the bits to the left by a specified amount, n,\nwrapping the truncated bits to the end of the resulting integer.
Please note this isn’t the same operation as the << shifting operator!
nonzero_bitwise #128281)Shifts the bits to the right by a specified amount, n,\nwrapping the truncated bits to the beginning of the resulting\ninteger.
Please note this isn’t the same operation as the >> shifting operator!
nonzero_bitwise #128281)Reverses the byte order of the integer.
\nnonzero_bitwise #128281)Reverses the order of bits in the integer. The least significant bit becomes the most significant bit,\nsecond least-significant bit becomes second most-significant bit, etc.
\nnonzero_bitwise #128281)Converts an integer from big endian to the target’s endianness.
\nOn big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts an integer from little endian to the target’s endianness.
\nOn little endian this is a no-op. On big endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to big endian from the target’s endianness.
On big endian this is a no-op. On little endian the bytes are\nswapped.
\nnonzero_bitwise #128281)Converts self to little endian from the target’s endianness.
On little endian this is a no-op. On big endian the bytes are\nswapped.
\nAdds an unsigned integer to a non-zero value.\nReturn NonZero::<usize>::MAX on overflow.
nonzero_ops #84186)Adds an unsigned integer to a non-zero value,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself + rhs > usize::MAX.
Returns the smallest power of two greater than or equal to self.\nChecks for overflow and returns None\nif the next power of two is greater than the type’s maximum value.\nAs a consequence, the result cannot wrap to zero.
let two = NonZero::new(2usize)?;\nlet three = NonZero::new(3usize)?;\nlet four = NonZero::new(4usize)?;\nlet max = NonZero::new(usize::MAX)?;\n\nassert_eq!(Some(two), two.checked_next_power_of_two() );\nassert_eq!(Some(four), three.checked_next_power_of_two() );\nassert_eq!(None, max.checked_next_power_of_two() );Returns the base 2 logarithm of the number, rounded down.
\nThis is the same operation as\nusize::ilog2,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Returns the base 10 logarithm of the number, rounded down.
\nThis is the same operation as\nusize::ilog10,\nexcept that it has no failure cases to worry about\nsince this value can never be zero.
Calculates the midpoint (average) between self and rhs.
midpoint(a, b) is (a + b) >> 1 as if it were performed in a\nsufficiently-large signed integral type. This implies that the result is\nalways rounded towards negative infinity and that no overflow will ever occur.
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()\non the underlying integer type, as special handling of zero can be avoided.
Returns the square root of the number, rounded down.
\nReturns the bit pattern of self reinterpreted as a signed integer of the same size.
Multiplies two non-zero integers together.\nReturn NonZero::<usize>::MAX on overflow.
nonzero_ops #84186)Multiplies two non-zero integers together,\nassuming overflow cannot occur.\nOverflow is unchecked, and it is undefined behavior to overflow\neven if the result would wrap to a non-zero value.\nThe behavior is undefined as soon as\nself * rhs > usize::MAX.
Raise non-zero value to an integer power.\nReturn NonZero::<usize>::MAX on overflow.