Struct gprimitives::NonZeroU256
source · 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 unsafe fn new_unchecked(n: U256) -> Self
pub const unsafe fn new_unchecked(n: U256) -> Self
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<Self>
pub fn checked_add(self, other: U256) -> Option<Self>
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) -> Self
pub fn saturating_add(self, other: U256) -> Self
Adds an unsigned integer to a non-zero value.
sourcepub fn overflowing_add(self, other: U256) -> (Self, bool)
pub fn overflowing_add(self, other: U256) -> (Self, bool)
Addition which overflows and returns a flag if it does.
sourcepub fn checked_sub(self, other: U256) -> Option<Self>
pub fn checked_sub(self, other: U256) -> Option<Self>
Checked subtraction. Returns None if overflow occurred.
sourcepub fn saturating_sub(self, other: U256) -> Self
pub fn saturating_sub(self, other: U256) -> Self
Subtraction which saturates at MIN.
sourcepub fn overflowing_sub(self, other: U256) -> (Self, bool)
pub fn overflowing_sub(self, other: U256) -> (Self, bool)
Subtraction which underflows and returns a flag if it does.
sourcepub fn checked_mul(self, other: Self) -> Option<Self>
pub fn checked_mul(self, other: Self) -> Option<Self>
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: Self) -> Self
pub fn saturating_mul(self, other: Self) -> Self
Multiplies two non-zero integers together.
sourcepub fn overflowing_mul(self, other: Self) -> (Self, bool)
pub fn overflowing_mul(self, other: Self) -> (Self, bool)
Multiply with overflow, returning a flag if it does.
sourcepub fn checked_pow(self, other: U256) -> Option<Self>
pub fn checked_pow(self, other: U256) -> Option<Self>
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) -> (Self, bool)
pub fn overflowing_pow(self, other: U256) -> (Self, bool)
Raise non-zero value to an integer power.
sourcepub fn pow(self, other: U256) -> Self
pub fn pow(self, other: U256) -> Self
Fast exponentiation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring
§Panics
Panics if the result overflows the type.
Trait Implementations§
source§impl<'a, T> Add<T> for &'a NonZeroU256
impl<'a, T> Add<T> for &'a NonZeroU256
§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
§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
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 Display for NonZeroU256
impl Display for NonZeroU256
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<NonZero<u128>> for NonZeroU256
impl From<NonZero<u128>> for NonZeroU256
source§fn from(value: NonZeroU128) -> Self
fn from(value: NonZeroU128) -> Self
source§impl From<NonZero<u16>> for NonZeroU256
impl From<NonZero<u16>> for NonZeroU256
source§fn from(value: NonZeroU16) -> Self
fn from(value: NonZeroU16) -> Self
source§impl From<NonZero<u32>> for NonZeroU256
impl From<NonZero<u32>> for NonZeroU256
source§fn from(value: NonZeroU32) -> Self
fn from(value: NonZeroU32) -> Self
source§impl From<NonZero<u64>> for NonZeroU256
impl From<NonZero<u64>> for NonZeroU256
source§fn from(value: NonZeroU64) -> Self
fn from(value: NonZeroU64) -> Self
source§impl From<NonZeroU256> for U256
impl From<NonZeroU256> for U256
source§fn from(nonzero: NonZeroU256) -> Self
fn from(nonzero: NonZeroU256) -> Self
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
§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<'a> Mul<NonZeroU256> for &'a NonZeroU256
impl<'a> Mul<NonZeroU256> for &'a NonZeroU256
§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
§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
§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 PartialEq for NonZeroU256
impl PartialEq for NonZeroU256
source§impl PartialOrd for NonZeroU256
impl PartialOrd for NonZeroU256
source§impl<'a, T> Sub<T> for &'a NonZeroU256
impl<'a, T> Sub<T> for &'a NonZeroU256
§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
§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 UpperHex for NonZeroU256
impl UpperHex for NonZeroU256
impl Copy 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)