Struct crypto_bigint::NonZero

source ·
pub struct NonZero<T: Zero>(_);
Expand description

Wrapper type for non-zero integers.

Implementations§

source§

impl<T> NonZero<T>where T: Zero,

source

pub fn new(n: T) -> CtOption<Self>

Create a new non-zero integer.

source§

impl<T> NonZero<T>where T: Integer,

source

pub const ONE: Self = _

The value 1.

source

pub const MAX: Self = _

Maximum value this integer can express.

source§

impl<T> NonZero<T>where T: Encoding + Zero,

source

pub fn from_be_bytes(bytes: T::Repr) -> CtOption<Self>

Decode from big endian bytes.

source

pub fn from_le_bytes(bytes: T::Repr) -> CtOption<Self>

Decode from little endian bytes.

source§

impl<T> NonZero<T>where T: ArrayEncoding + Zero,

source

pub fn from_be_byte_array(bytes: ByteArray<T>) -> CtOption<Self>

Decode a non-zero integer from big endian bytes.

source

pub fn from_le_byte_array(bytes: ByteArray<T>) -> CtOption<Self>

Decode a non-zero integer from big endian bytes.

source§

impl NonZero<Limb>

source

pub const fn from_u8(n: NonZeroU8) -> Self

Create a NonZero<Limb> from a NonZeroU8 (const-friendly)

source

pub const fn from_u16(n: NonZeroU16) -> Self

Create a NonZero<Limb> from a NonZeroU16 (const-friendly)

source

pub const fn from_u32(n: NonZeroU32) -> Self

Create a NonZero<Limb> from a NonZeroU32 (const-friendly)

source

pub const fn from_u64(n: NonZeroU64) -> Self

Create a NonZero<Limb> from a NonZeroU64 (const-friendly)

source§

impl<const LIMBS: usize> NonZero<UInt<LIMBS>>

source

pub const fn from_uint(n: UInt<LIMBS>) -> Self

Create a NonZero<UInt> from a UInt (const-friendly)

source

pub const fn from_u8(n: NonZeroU8) -> Self

Create a NonZero<UInt> from a NonZeroU8 (const-friendly)

source

pub const fn from_u16(n: NonZeroU16) -> Self

Create a NonZero<UInt> from a NonZeroU16 (const-friendly)

source

pub const fn from_u32(n: NonZeroU32) -> Self

Create a NonZero<UInt> from a NonZeroU32 (const-friendly)

source

pub const fn from_u64(n: NonZeroU64) -> Self

Create a NonZero<UInt> from a NonZeroU64 (const-friendly)

source

pub const fn from_u128(n: NonZeroU128) -> Self

Create a NonZero<UInt> from a NonZeroU128 (const-friendly)

Trait Implementations§

source§

impl<T> AsRef<T> for NonZero<T>where T: Zero,

source§

fn as_ref(&self) -> &T

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

impl<T> Binary for NonZero<T>where T: Binary + Zero,

source§

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

Formats the value using the given formatter.
source§

impl<T: Clone + Zero> Clone for NonZero<T>

source§

fn clone(&self) -> NonZero<T>

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<T> ConditionallySelectable for NonZero<T>where T: ConditionallySelectable + Zero,

source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
source§

impl<T> ConstantTimeEq for NonZero<T>where T: Zero,

source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
source§

impl<T: Debug + Zero> Debug for NonZero<T>

source§

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

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

impl<T: Default + Zero> Default for NonZero<T>

source§

fn default() -> NonZero<T>

Returns the “default value” for a type. Read more
source§

impl<T> Deref for NonZero<T>where T: Zero,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T> Display for NonZero<T>where T: Display + Zero,

source§

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

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

impl<const LIMBS: usize> Div<&NonZero<UInt<LIMBS>>> for &UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<&NonZero<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<&NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<&NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<NonZero<UInt<LIMBS>>> for &UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the / operator.
source§

fn div(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<NonZero<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the / operator.
source§

fn div(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> Div<NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the / operator.
source§

fn div(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the / operation. Read more
source§

impl<const LIMBS: usize> DivAssign<&NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

source§

fn div_assign(&mut self, rhs: &NonZero<UInt<LIMBS>>)

Performs the /= operation. Read more
source§

impl<const LIMBS: usize> DivAssign<&NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

source§

fn div_assign(&mut self, rhs: &NonZero<UInt<LIMBS>>)

Performs the /= operation. Read more
source§

impl<const LIMBS: usize> DivAssign<NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

source§

fn div_assign(&mut self, rhs: NonZero<UInt<LIMBS>>)

Performs the /= operation. Read more
source§

impl<const LIMBS: usize> DivAssign<NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

source§

fn div_assign(&mut self, rhs: NonZero<UInt<LIMBS>>)

Performs the /= operation. Read more
source§

impl<const LIMBS: usize> From<NonZeroU128> for NonZero<UInt<LIMBS>>

source§

fn from(integer: NonZeroU128) -> Self

Converts to this type from the input type.
source§

impl From<NonZeroU16> for NonZero<Limb>

source§

fn from(integer: NonZeroU16) -> Self

Converts to this type from the input type.
source§

impl<const LIMBS: usize> From<NonZeroU16> for NonZero<UInt<LIMBS>>

source§

fn from(integer: NonZeroU16) -> Self

Converts to this type from the input type.
source§

impl From<NonZeroU32> for NonZero<Limb>

source§

fn from(integer: NonZeroU32) -> Self

Converts to this type from the input type.
source§

impl<const LIMBS: usize> From<NonZeroU32> for NonZero<UInt<LIMBS>>

source§

fn from(integer: NonZeroU32) -> Self

Converts to this type from the input type.
source§

impl From<NonZeroU64> for NonZero<Limb>

source§

fn from(integer: NonZeroU64) -> Self

Converts to this type from the input type.
source§

impl<const LIMBS: usize> From<NonZeroU64> for NonZero<UInt<LIMBS>>

source§

fn from(integer: NonZeroU64) -> Self

Converts to this type from the input type.
source§

impl From<NonZeroU8> for NonZero<Limb>

source§

fn from(integer: NonZeroU8) -> Self

Converts to this type from the input type.
source§

impl<const LIMBS: usize> From<NonZeroU8> for NonZero<UInt<LIMBS>>

source§

fn from(integer: NonZeroU8) -> Self

Converts to this type from the input type.
source§

impl<T> LowerHex for NonZero<T>where T: LowerHex + Zero,

source§

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

Formats the value using the given formatter.
source§

impl<T> Octal for NonZero<T>where T: Octal + Zero,

source§

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

Formats the value using the given formatter.
source§

impl<T: Ord + Zero> Ord for NonZero<T>

source§

fn cmp(&self, other: &NonZero<T>) -> Ordering

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

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

impl<T: PartialEq + Zero> PartialEq<NonZero<T>> for NonZero<T>

source§

fn eq(&self, other: &NonZero<T>) -> bool

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

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

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

impl<T: PartialOrd + Zero> PartialOrd<NonZero<T>> for NonZero<T>

source§

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

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

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

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

impl<T> Random for NonZero<T>where T: Random + Zero,

source§

fn random(rng: impl CryptoRng + RngCore) -> Self

Generate a random NonZero<T>.

source§

impl<const LIMBS: usize> Rem<&NonZero<UInt<LIMBS>>> for &UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<&NonZero<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<&NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<&NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: &NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<NonZero<UInt<LIMBS>>> for &UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<NonZero<UInt<LIMBS>>> for &Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

§

type Output = UInt<LIMBS>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> Rem<NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

§

type Output = Wrapping<UInt<LIMBS>>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: NonZero<UInt<LIMBS>>) -> Self::Output

Performs the % operation. Read more
source§

impl<const LIMBS: usize> RemAssign<&NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

source§

fn rem_assign(&mut self, rhs: &NonZero<UInt<LIMBS>>)

Performs the %= operation. Read more
source§

impl<const LIMBS: usize> RemAssign<&NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

source§

fn rem_assign(&mut self, rhs: &NonZero<UInt<LIMBS>>)

Performs the %= operation. Read more
source§

impl<const LIMBS: usize> RemAssign<NonZero<UInt<LIMBS>>> for UInt<LIMBS>where UInt<LIMBS>: Integer,

source§

fn rem_assign(&mut self, rhs: NonZero<UInt<LIMBS>>)

Performs the %= operation. Read more
source§

impl<const LIMBS: usize> RemAssign<NonZero<UInt<LIMBS>>> for Wrapping<UInt<LIMBS>>

source§

fn rem_assign(&mut self, rhs: NonZero<UInt<LIMBS>>)

Performs the %= operation. Read more
source§

impl<T> UpperHex for NonZero<T>where T: UpperHex + Zero,

source§

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

Formats the value using the given formatter.
source§

impl<T: Copy + Zero> Copy for NonZero<T>

source§

impl<T: Eq + Zero> Eq for NonZero<T>

source§

impl<T: Zero> StructuralEq for NonZero<T>

source§

impl<T: Zero> StructuralPartialEq for NonZero<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for NonZero<T>where T: RefUnwindSafe,

§

impl<T> Send for NonZero<T>where T: Send,

§

impl<T> Sync for NonZero<T>where T: Sync,

§

impl<T> Unpin for NonZero<T>where T: Unpin,

§

impl<T> UnwindSafe for NonZero<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere 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.