Struct gprimitives::NonZeroU256

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

A value that is known not to equal zero.

Implementations§

source§

impl NonZeroU256

source

pub const MIN: NonZeroU256 = _

The smallest value that can be represented by this non-zero

source

pub const MAX: NonZeroU256 = _

The largest value that can be represented by this non-zero

source

pub const fn new(n: U256) -> Option<Self>

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

source

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.

source

pub const fn get(self) -> U256

Returns the contained value as a primitive type.

source

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.

source

pub fn saturating_add(self, other: U256) -> Self

Adds an unsigned integer to a non-zero value.

source

pub fn overflowing_add(self, other: U256) -> (Self, bool)

Addition which overflows and returns a flag if it does.

source

pub fn checked_sub(self, other: U256) -> Option<Self>

Checked subtraction. Returns None if overflow occurred.

source

pub fn saturating_sub(self, other: U256) -> Self

Subtraction which saturates at MIN.

source

pub fn overflowing_sub(self, other: U256) -> (Self, bool)

Subtraction which underflows and returns a flag if it does.

source

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.

source

pub fn saturating_mul(self, other: Self) -> Self

Multiplies two non-zero integers together.

source

pub fn overflowing_mul(self, other: Self) -> (Self, bool)

Multiply with overflow, returning a flag if it does.

source

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.

source

pub fn overflowing_pow(self, other: U256) -> (Self, bool)

Raise non-zero value to an integer power.

source

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
where T: Into<U256>,

§

type Output = NonZeroU256

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> NonZeroU256

Performs the + operation. Read more
source§

impl<T> Add<T> for NonZeroU256
where T: Into<U256>,

§

type Output = NonZeroU256

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> NonZeroU256

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for NonZeroU256
where T: Into<U256>,

source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
source§

impl AsRef<[u64]> for NonZeroU256

Get a reference to the underlying little-endian words.

source§

fn as_ref(&self) -> &[u64]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for NonZeroU256

source§

fn clone(&self) -> NonZeroU256

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

impl Debug for NonZeroU256

source§

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

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

impl Display for NonZeroU256

source§

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

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

impl<'a> From<&'a NonZeroU256> for NonZeroU256

source§

fn from(x: &'a NonZeroU256) -> NonZeroU256

Converts to this type from the input type.
source§

impl From<NonZero<u128>> for NonZeroU256

source§

fn from(value: NonZeroU128) -> Self

Converts to this type from the input type.
source§

impl From<NonZero<u16>> for NonZeroU256

source§

fn from(value: NonZeroU16) -> Self

Converts to this type from the input type.
source§

impl From<NonZero<u32>> for NonZeroU256

source§

fn from(value: NonZeroU32) -> Self

Converts to this type from the input type.
source§

impl From<NonZero<u64>> for NonZeroU256

source§

fn from(value: NonZeroU64) -> Self

Converts to this type from the input type.
source§

impl From<NonZero<u8>> for NonZeroU256

source§

fn from(value: NonZeroU8) -> Self

Converts to this type from the input type.
source§

impl From<NonZeroU256> for U256

source§

fn from(nonzero: NonZeroU256) -> Self

Converts to this type from the input type.
source§

impl Hash for NonZeroU256

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 NonZeroU256

source§

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

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

impl<'a> Mul<&'a NonZeroU256> for NonZeroU256

§

type Output = NonZeroU256

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a NonZeroU256) -> NonZeroU256

Performs the * operation. Read more
source§

impl<'a> Mul<NonZeroU256> for &'a NonZeroU256

§

type Output = NonZeroU256

The resulting type after applying the * operator.
source§

fn mul(self, other: NonZeroU256) -> NonZeroU256

Performs the * operation. Read more
source§

impl<'a> Mul for &'a NonZeroU256

§

type Output = NonZeroU256

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a NonZeroU256) -> NonZeroU256

Performs the * operation. Read more
source§

impl Mul for NonZeroU256

§

type Output = NonZeroU256

The resulting type after applying the * operator.
source§

fn mul(self, other: NonZeroU256) -> NonZeroU256

Performs the * operation. Read more
source§

impl MulAssign for NonZeroU256

source§

fn mul_assign(&mut self, other: NonZeroU256)

Performs the *= operation. Read more
source§

impl Ord for NonZeroU256

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Self

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

impl PartialEq for NonZeroU256

source§

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

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

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

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

impl PartialOrd for NonZeroU256

source§

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

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

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

Tests less than (for self and other) and is used by the < operator. Read more
source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T> Sub<T> for &'a NonZeroU256
where T: Into<U256>,

§

type Output = NonZeroU256

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> NonZeroU256

Performs the - operation. Read more
source§

impl<T> Sub<T> for NonZeroU256
where T: Into<U256>,

§

type Output = NonZeroU256

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> NonZeroU256

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for NonZeroU256
where T: Into<U256>,

source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
source§

impl TryFrom<u128> for NonZeroU256

§

type Error = &'static str

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

fn try_from(value: u128) -> Result<NonZeroU256, &'static str>

Performs the conversion.
source§

impl TryFrom<u16> for NonZeroU256

§

type Error = &'static str

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

fn try_from(value: u16) -> Result<NonZeroU256, &'static str>

Performs the conversion.
source§

impl TryFrom<u32> for NonZeroU256

§

type Error = &'static str

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

fn try_from(value: u32) -> Result<NonZeroU256, &'static str>

Performs the conversion.
source§

impl TryFrom<u64> for NonZeroU256

§

type Error = &'static str

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

fn try_from(value: u64) -> Result<NonZeroU256, &'static str>

Performs the conversion.
source§

impl TryFrom<u8> for NonZeroU256

§

type Error = &'static str

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

fn try_from(value: u8) -> Result<NonZeroU256, &'static str>

Performs the conversion.
source§

impl UpperHex for NonZeroU256

source§

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

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

impl Copy for NonZeroU256

source§

impl Eq for NonZeroU256

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T, U> AsByteSlice<T> for U
where T: ToByteSlice, U: AsRef<[T]> + ?Sized,

source§

fn as_byte_slice(&self) -> &[u8]

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> JsonSchemaMaybe for T