Struct NonZero
pub struct NonZero<T>(/* private fields */)
where
T: Zero;Expand description
Wrapper type for non-zero integers.
Implementations§
§impl<T> NonZero<T>
impl<T> NonZero<T>
pub fn from_be_bytes(bytes: <T as Encoding>::Repr) -> CtOption<NonZero<T>>
pub fn from_be_bytes(bytes: <T as Encoding>::Repr) -> CtOption<NonZero<T>>
Decode from big endian bytes.
pub fn from_le_bytes(bytes: <T as Encoding>::Repr) -> CtOption<NonZero<T>>
pub fn from_le_bytes(bytes: <T as Encoding>::Repr) -> CtOption<NonZero<T>>
Decode from little endian bytes.
§impl<T> NonZero<T>where
T: ArrayEncoding + Zero,
impl<T> NonZero<T>where
T: ArrayEncoding + Zero,
pub fn from_be_byte_array(
bytes: GenericArray<u8, <T as ArrayEncoding>::ByteSize>,
) -> CtOption<NonZero<T>>
pub fn from_be_byte_array( bytes: GenericArray<u8, <T as ArrayEncoding>::ByteSize>, ) -> CtOption<NonZero<T>>
Decode a non-zero integer from big endian bytes.
pub fn from_le_byte_array(
bytes: GenericArray<u8, <T as ArrayEncoding>::ByteSize>,
) -> CtOption<NonZero<T>>
pub fn from_le_byte_array( bytes: GenericArray<u8, <T as ArrayEncoding>::ByteSize>, ) -> CtOption<NonZero<T>>
Decode a non-zero integer from big endian bytes.
§impl NonZero<Limb>
impl NonZero<Limb>
pub const fn from_u8(n: NonZero<u8>) -> NonZero<Limb>
pub const fn from_u8(n: NonZero<u8>) -> NonZero<Limb>
Create a NonZero<Limb> from a NonZeroU8 (const-friendly)
pub const fn from_u16(n: NonZero<u16>) -> NonZero<Limb>
pub const fn from_u16(n: NonZero<u16>) -> NonZero<Limb>
Create a NonZero<Limb> from a NonZeroU16 (const-friendly)
pub const fn from_u32(n: NonZero<u32>) -> NonZero<Limb>
pub const fn from_u32(n: NonZero<u32>) -> NonZero<Limb>
Create a NonZero<Limb> from a NonZeroU32 (const-friendly)
pub const fn from_u64(n: NonZero<u64>) -> NonZero<Limb>
pub const fn from_u64(n: NonZero<u64>) -> NonZero<Limb>
Create a NonZero<Limb> from a NonZeroU64 (const-friendly)
§impl<const LIMBS: usize> NonZero<Uint<LIMBS>>
impl<const LIMBS: usize> NonZero<Uint<LIMBS>>
pub const fn from_uint(n: Uint<LIMBS>) -> NonZero<Uint<LIMBS>>
pub const fn from_uint(n: Uint<LIMBS>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a Uint (const-friendly)
pub const fn from_u8(n: NonZero<u8>) -> NonZero<Uint<LIMBS>>
pub const fn from_u8(n: NonZero<u8>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a NonZeroU8 (const-friendly)
pub const fn from_u16(n: NonZero<u16>) -> NonZero<Uint<LIMBS>>
pub const fn from_u16(n: NonZero<u16>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a NonZeroU16 (const-friendly)
pub const fn from_u32(n: NonZero<u32>) -> NonZero<Uint<LIMBS>>
pub const fn from_u32(n: NonZero<u32>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a NonZeroU32 (const-friendly)
pub const fn from_u64(n: NonZero<u64>) -> NonZero<Uint<LIMBS>>
pub const fn from_u64(n: NonZero<u64>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a NonZeroU64 (const-friendly)
pub const fn from_u128(n: NonZero<u128>) -> NonZero<Uint<LIMBS>>
pub const fn from_u128(n: NonZero<u128>) -> NonZero<Uint<LIMBS>>
Create a NonZero<Uint> from a NonZeroU128 (const-friendly)
Trait Implementations§
§impl<T> ConditionallySelectable for NonZero<T>where
T: ConditionallySelectable + Zero,
impl<T> ConditionallySelectable for NonZero<T>where
T: ConditionallySelectable + Zero,
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
self and other if choice == 1; otherwise,
reassign both unto themselves. Read more§impl<T> ConstantTimeEq for NonZero<T>where
T: Zero,
impl<T> ConstantTimeEq for NonZero<T>where
T: Zero,
§impl<const LIMBS: usize> DivAssign<&NonZero<Limb>> for Uint<LIMBS>
impl<const LIMBS: usize> DivAssign<&NonZero<Limb>> for Uint<LIMBS>
§fn div_assign(&mut self, rhs: &NonZero<Limb>)
fn div_assign(&mut self, rhs: &NonZero<Limb>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<&NonZero<Limb>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> DivAssign<&NonZero<Limb>> for Wrapping<Uint<LIMBS>>
§fn div_assign(&mut self, rhs: &NonZero<Limb>)
fn div_assign(&mut self, rhs: &NonZero<Limb>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<&NonZero<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> DivAssign<&NonZero<Uint<LIMBS>>> for Uint<LIMBS>
§fn div_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
fn div_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<&NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> DivAssign<&NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
§fn div_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
fn div_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<NonZero<Limb>> for Uint<LIMBS>
impl<const LIMBS: usize> DivAssign<NonZero<Limb>> for Uint<LIMBS>
§fn div_assign(&mut self, rhs: NonZero<Limb>)
fn div_assign(&mut self, rhs: NonZero<Limb>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<NonZero<Limb>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> DivAssign<NonZero<Limb>> for Wrapping<Uint<LIMBS>>
§fn div_assign(&mut self, rhs: NonZero<Limb>)
fn div_assign(&mut self, rhs: NonZero<Limb>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<NonZero<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> DivAssign<NonZero<Uint<LIMBS>>> for Uint<LIMBS>
§fn div_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
fn div_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
/= operation. Read more§impl<const LIMBS: usize> DivAssign<NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> DivAssign<NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
§fn div_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
fn div_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
/= operation. Read more§impl<MOD, const LIMBS: usize> Invert for NonZero<Residue<MOD, LIMBS>>where
MOD: ResidueParams<LIMBS>,
impl<MOD, const LIMBS: usize> Invert for NonZero<Residue<MOD, LIMBS>>where
MOD: ResidueParams<LIMBS>,
§impl<T> Ord for NonZero<T>
impl<T> Ord for NonZero<T>
§impl<T> PartialOrd for NonZero<T>where
T: PartialOrd + Zero,
impl<T> PartialOrd for NonZero<T>where
T: PartialOrd + Zero,
§impl<T> Random for NonZero<T>
Available on crate feature rand_core only.
impl<T> Random for NonZero<T>
rand_core only.§fn random(rng: &mut impl CryptoRngCore) -> NonZero<T>
fn random(rng: &mut impl CryptoRngCore) -> NonZero<T>
Generate a random NonZero<T>.
§impl<const LIMBS: usize> RemAssign<&NonZero<Limb>> for Uint<LIMBS>
impl<const LIMBS: usize> RemAssign<&NonZero<Limb>> for Uint<LIMBS>
§fn rem_assign(&mut self, rhs: &NonZero<Limb>)
fn rem_assign(&mut self, rhs: &NonZero<Limb>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<&NonZero<Limb>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> RemAssign<&NonZero<Limb>> for Wrapping<Uint<LIMBS>>
§fn rem_assign(&mut self, rhs: &NonZero<Limb>)
fn rem_assign(&mut self, rhs: &NonZero<Limb>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<&NonZero<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> RemAssign<&NonZero<Uint<LIMBS>>> for Uint<LIMBS>
§fn rem_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
fn rem_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<&NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> RemAssign<&NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
§fn rem_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
fn rem_assign(&mut self, rhs: &NonZero<Uint<LIMBS>>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<NonZero<Limb>> for Uint<LIMBS>
impl<const LIMBS: usize> RemAssign<NonZero<Limb>> for Uint<LIMBS>
§fn rem_assign(&mut self, rhs: NonZero<Limb>)
fn rem_assign(&mut self, rhs: NonZero<Limb>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<NonZero<Limb>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> RemAssign<NonZero<Limb>> for Wrapping<Uint<LIMBS>>
§fn rem_assign(&mut self, rhs: NonZero<Limb>)
fn rem_assign(&mut self, rhs: NonZero<Limb>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<NonZero<Uint<LIMBS>>> for Uint<LIMBS>
impl<const LIMBS: usize> RemAssign<NonZero<Uint<LIMBS>>> for Uint<LIMBS>
§fn rem_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
fn rem_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
%= operation. Read more§impl<const LIMBS: usize> RemAssign<NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
impl<const LIMBS: usize> RemAssign<NonZero<Uint<LIMBS>>> for Wrapping<Uint<LIMBS>>
§fn rem_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
fn rem_assign(&mut self, rhs: NonZero<Uint<LIMBS>>)
%= operation. Read moreimpl<T> Copy for NonZero<T>
impl<T> Eq for NonZero<T>
impl<T> StructuralPartialEq for NonZero<T>where
T: Zero,
Auto Trait Implementations§
impl<T> Freeze for NonZero<T>where
T: Freeze,
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> 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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more