NonZeroU256

Struct 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<NonZeroU256>

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

Source

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.

Source

pub const fn get(self) -> U256

Returns the contained value as a primitive type.

Source

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.

Source

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

Adds an unsigned integer to a non-zero value.

Source

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

Addition which overflows and returns a flag if it does.

Source

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

Checked subtraction. Returns None if overflow occurred.

Source

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

Subtraction which saturates at MIN.

Source

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

Subtraction which underflows and returns a flag if it does.

Source

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.

Source

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

Multiplies two non-zero integers together.

Source

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

Multiply with overflow, returning a flag if it does.

Source

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.

Source

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

Raise non-zero value to an integer power.

Source

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

Source§

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>,

Source§

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 duplicate 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<(), Error>

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

impl Decode for NonZeroU256

Source§

fn decode<I>(input: &mut I) -> Result<NonZeroU256, Error>
where I: Input,

Attempt to deserialise the value from input.
Source§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
Source§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl Display for NonZeroU256

Source§

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

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

impl Encode for NonZeroU256

Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encode_to<W>(&self, dest: &mut W)
where W: Output + ?Sized,

Convert self to a slice and append it to the destination.
Source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
Source§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
Source§

fn encoded_size(&self) -> usize

Calculates the encoded size. 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: NonZero<u128>) -> NonZeroU256

Converts to this type from the input type.
Source§

impl From<NonZero<u16>> for NonZeroU256

Source§

fn from(value: NonZero<u16>) -> NonZeroU256

Converts to this type from the input type.
Source§

impl From<NonZero<u32>> for NonZeroU256

Source§

fn from(value: NonZero<u32>) -> NonZeroU256

Converts to this type from the input type.
Source§

impl From<NonZero<u64>> for NonZeroU256

Source§

fn from(value: NonZero<u64>) -> NonZeroU256

Converts to this type from the input type.
Source§

impl From<NonZero<u8>> for NonZeroU256

Source§

fn from(value: NonZero<u8>) -> NonZeroU256

Converts to this type from the input type.
Source§

impl From<NonZeroU256> for U256

Source§

fn from(nonzero: NonZeroU256) -> U256

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<(), Error>

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

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

Source§

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<NonZeroU256> for &NonZeroU256

Source§

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

Source§

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

Source§

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: &NonZeroU256) -> Ordering

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

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

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

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

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

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

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

impl PartialEq for NonZeroU256

Source§

fn eq(&self, other: &NonZeroU256) -> 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: &NonZeroU256) -> Option<Ordering>

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

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

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

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

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

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

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

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

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

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

Source§

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>,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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 TypeInfo for NonZeroU256

Source§

type Identity = NonZeroU256

The type identifying for which type info is provided. Read more
Source§

fn type_info() -> Type

Returns the static type identifier for Self.
Source§

impl UpperHex for NonZeroU256

Source§

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

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

impl Copy for NonZeroU256

Source§

impl EncodeLike 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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DecodeAll for T
where T: Decode,

Source§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

impl<T> DecodeLimit for T
where T: Decode,

Source§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8], ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
Source§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> KeyedVec for T
where T: Codec,

Source§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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§

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>,

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<S> Codec for S
where S: Decode + Encode,

Source§

impl<T> EncodeLike<&&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&T> for T
where T: Encode,

Source§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

Source§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

Source§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

Source§

impl<T> EncodeLike<Cow<'_, T>> for T
where T: ToOwned + Encode,

Source§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

Source§

impl<S> FullCodec for S
where S: Decode + FullEncode,

Source§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

Source§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,