pub struct NonZeroU256(/* private fields */);Expand description
A value that is known not to equal zero.
Implementations§
Source§impl NonZeroU256
impl NonZeroU256
Sourcepub const MIN: NonZeroU256
pub const MIN: NonZeroU256
The smallest value that can be represented by this non-zero
Sourcepub const MAX: NonZeroU256
pub const MAX: NonZeroU256
The largest value that can be represented by this non-zero
Sourcepub const fn new(n: U256) -> Option<NonZeroU256>
pub const fn new(n: U256) -> Option<NonZeroU256>
Creates a non-zero if the given value is not zero.
Sourcepub const unsafe fn new_unchecked(n: U256) -> NonZeroU256
pub const unsafe fn new_unchecked(n: U256) -> NonZeroU256
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.
Sourcepub fn checked_add(self, other: U256) -> Option<NonZeroU256>
pub fn checked_add(self, other: U256) -> Option<NonZeroU256>
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.
Sourcepub fn saturating_add(self, other: U256) -> NonZeroU256
pub fn saturating_add(self, other: U256) -> NonZeroU256
Adds an unsigned integer to a non-zero value.
Sourcepub fn overflowing_add(self, other: U256) -> (NonZeroU256, bool)
pub fn overflowing_add(self, other: U256) -> (NonZeroU256, bool)
Addition which overflows and returns a flag if it does.
Sourcepub fn checked_sub(self, other: U256) -> Option<NonZeroU256>
pub fn checked_sub(self, other: U256) -> Option<NonZeroU256>
Checked subtraction. Returns None if overflow occurred.
Sourcepub fn saturating_sub(self, other: U256) -> NonZeroU256
pub fn saturating_sub(self, other: U256) -> NonZeroU256
Subtraction which saturates at MIN.
Sourcepub fn overflowing_sub(self, other: U256) -> (NonZeroU256, bool)
pub fn overflowing_sub(self, other: U256) -> (NonZeroU256, bool)
Subtraction which underflows and returns a flag if it does.
Sourcepub fn checked_mul(self, other: NonZeroU256) -> Option<NonZeroU256>
pub fn checked_mul(self, other: NonZeroU256) -> Option<NonZeroU256>
Multiplies two non-zero integers together.
Checks for overflow and returns None on overflow.
As a consequence, the result cannot wrap to zero.
Sourcepub fn saturating_mul(self, other: NonZeroU256) -> NonZeroU256
pub fn saturating_mul(self, other: NonZeroU256) -> NonZeroU256
Multiplies two non-zero integers together.
Sourcepub fn overflowing_mul(self, other: NonZeroU256) -> (NonZeroU256, bool)
pub fn overflowing_mul(self, other: NonZeroU256) -> (NonZeroU256, bool)
Multiply with overflow, returning a flag if it does.
Sourcepub fn checked_pow(self, other: U256) -> Option<NonZeroU256>
pub fn checked_pow(self, other: U256) -> Option<NonZeroU256>
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.
Sourcepub fn overflowing_pow(self, other: U256) -> (NonZeroU256, bool)
pub fn overflowing_pow(self, other: U256) -> (NonZeroU256, bool)
Raise non-zero value to an integer power.
Sourcepub fn pow(self, other: U256) -> NonZeroU256
pub fn pow(self, other: U256) -> NonZeroU256
Fast exponentiation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring
§Panics
Panics if the result overflows the type.
Trait Implementations§
Source§impl<T> Add<T> for &NonZeroU256
impl<T> Add<T> for &NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
+ operator.Source§fn add(self, other: T) -> NonZeroU256
fn add(self, other: T) -> NonZeroU256
+ operation. Read moreSource§impl<T> Add<T> for NonZeroU256
impl<T> Add<T> for NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
+ operator.Source§fn add(self, other: T) -> NonZeroU256
fn add(self, other: T) -> NonZeroU256
+ operation. Read moreSource§impl<T> AddAssign<T> for NonZeroU256
impl<T> AddAssign<T> for NonZeroU256
Source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+= operation. Read moreSource§impl AsRef<[u64]> for NonZeroU256
Get a reference to the underlying little-endian words.
impl AsRef<[u64]> for NonZeroU256
Get a reference to the underlying little-endian words.
Source§impl Clone for NonZeroU256
impl Clone for NonZeroU256
Source§fn clone(&self) -> NonZeroU256
fn clone(&self) -> NonZeroU256
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NonZeroU256
impl Debug for NonZeroU256
Source§impl Decode for NonZeroU256
impl Decode for NonZeroU256
Source§fn decode<I>(input: &mut I) -> Result<NonZeroU256, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<NonZeroU256, Error>where
I: Input,
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Source§impl Display for NonZeroU256
impl Display for NonZeroU256
Source§impl Encode for NonZeroU256
impl Encode for NonZeroU256
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Source§fn encode_to<W>(&self, dest: &mut W)
fn encode_to<W>(&self, dest: &mut W)
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Source§impl<'a> From<&'a NonZeroU256> for NonZeroU256
impl<'a> From<&'a NonZeroU256> for NonZeroU256
Source§fn from(x: &'a NonZeroU256) -> NonZeroU256
fn from(x: &'a NonZeroU256) -> NonZeroU256
Source§impl From<NonZeroU256> for U256
impl From<NonZeroU256> for U256
Source§fn from(nonzero: NonZeroU256) -> U256
fn from(nonzero: NonZeroU256) -> U256
Source§impl Hash for NonZeroU256
impl Hash for NonZeroU256
Source§impl LowerHex for NonZeroU256
impl LowerHex for NonZeroU256
Source§impl<'a> Mul<&'a NonZeroU256> for NonZeroU256
impl<'a> Mul<&'a NonZeroU256> for NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
* operator.Source§fn mul(self, other: &'a NonZeroU256) -> NonZeroU256
fn mul(self, other: &'a NonZeroU256) -> NonZeroU256
* operation. Read moreSource§impl Mul<NonZeroU256> for &NonZeroU256
impl Mul<NonZeroU256> for &NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
* operator.Source§fn mul(self, other: NonZeroU256) -> NonZeroU256
fn mul(self, other: NonZeroU256) -> NonZeroU256
* operation. Read moreSource§impl<'a> Mul for &'a NonZeroU256
impl<'a> Mul for &'a NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
* operator.Source§fn mul(self, other: &'a NonZeroU256) -> NonZeroU256
fn mul(self, other: &'a NonZeroU256) -> NonZeroU256
* operation. Read moreSource§impl Mul for NonZeroU256
impl Mul for NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
* operator.Source§fn mul(self, other: NonZeroU256) -> NonZeroU256
fn mul(self, other: NonZeroU256) -> NonZeroU256
* operation. Read moreSource§impl MulAssign for NonZeroU256
impl MulAssign for NonZeroU256
Source§fn mul_assign(&mut self, other: NonZeroU256)
fn mul_assign(&mut self, other: NonZeroU256)
*= operation. Read moreSource§impl Ord for NonZeroU256
impl Ord for NonZeroU256
Source§fn cmp(&self, other: &NonZeroU256) -> Ordering
fn cmp(&self, other: &NonZeroU256) -> Ordering
Source§fn max(self, other: NonZeroU256) -> NonZeroU256
fn max(self, other: NonZeroU256) -> NonZeroU256
Source§fn min(self, other: NonZeroU256) -> NonZeroU256
fn min(self, other: NonZeroU256) -> NonZeroU256
Source§fn clamp(self, min: NonZeroU256, max: NonZeroU256) -> NonZeroU256
fn clamp(self, min: NonZeroU256, max: NonZeroU256) -> NonZeroU256
Source§impl PartialEq for NonZeroU256
impl PartialEq for NonZeroU256
Source§impl PartialOrd for NonZeroU256
impl PartialOrd for NonZeroU256
Source§fn partial_cmp(&self, other: &NonZeroU256) -> Option<Ordering>
fn partial_cmp(&self, other: &NonZeroU256) -> Option<Ordering>
Source§fn lt(&self, other: &NonZeroU256) -> bool
fn lt(&self, other: &NonZeroU256) -> bool
Source§fn le(&self, other: &NonZeroU256) -> bool
fn le(&self, other: &NonZeroU256) -> bool
Source§fn gt(&self, other: &NonZeroU256) -> bool
fn gt(&self, other: &NonZeroU256) -> bool
Source§impl<T> Sub<T> for &NonZeroU256
impl<T> Sub<T> for &NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
- operator.Source§fn sub(self, other: T) -> NonZeroU256
fn sub(self, other: T) -> NonZeroU256
- operation. Read moreSource§impl<T> Sub<T> for NonZeroU256
impl<T> Sub<T> for NonZeroU256
Source§type Output = NonZeroU256
type Output = NonZeroU256
- operator.Source§fn sub(self, other: T) -> NonZeroU256
fn sub(self, other: T) -> NonZeroU256
- operation. Read moreSource§impl<T> SubAssign<T> for NonZeroU256
impl<T> SubAssign<T> for NonZeroU256
Source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-= operation. Read moreSource§impl TryFrom<u128> for NonZeroU256
impl TryFrom<u128> for NonZeroU256
Source§impl TryFrom<u16> for NonZeroU256
impl TryFrom<u16> for NonZeroU256
Source§impl TryFrom<u32> for NonZeroU256
impl TryFrom<u32> for NonZeroU256
Source§impl TryFrom<u64> for NonZeroU256
impl TryFrom<u64> for NonZeroU256
Source§impl TryFrom<u8> for NonZeroU256
impl TryFrom<u8> for NonZeroU256
Source§impl TypeInfo for NonZeroU256
impl TypeInfo for NonZeroU256
Source§impl UpperHex for NonZeroU256
impl UpperHex for NonZeroU256
impl Copy for NonZeroU256
impl EncodeLike for NonZeroU256
impl Eq for NonZeroU256
Auto Trait Implementations§
impl Freeze for NonZeroU256
impl RefUnwindSafe for NonZeroU256
impl Send for NonZeroU256
impl Sync for NonZeroU256
impl Unpin for NonZeroU256
impl UnwindSafe for NonZeroU256
Blanket Implementations§
Source§impl<T, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.