pub struct NonZero<T: Zero>(/* private fields */);
Expand description
Wrapper type for non-zero integers.
Implementations§
Source§impl<T> NonZero<T>
impl<T> NonZero<T>
Sourcepub fn from_be_bytes(bytes: T::Repr) -> CtOption<Self>
pub fn from_be_bytes(bytes: T::Repr) -> CtOption<Self>
Decode from big endian bytes.
Sourcepub fn from_le_bytes(bytes: T::Repr) -> CtOption<Self>
pub fn from_le_bytes(bytes: T::Repr) -> CtOption<Self>
Decode from little endian bytes.
Source§impl<T> NonZero<T>where
T: ArrayEncoding + Zero,
impl<T> NonZero<T>where
T: ArrayEncoding + Zero,
Sourcepub fn from_be_byte_array(bytes: ByteArray<T>) -> CtOption<Self>
pub fn from_be_byte_array(bytes: ByteArray<T>) -> CtOption<Self>
Decode a non-zero integer from big endian bytes.
Sourcepub fn from_le_byte_array(bytes: ByteArray<T>) -> CtOption<Self>
pub fn from_le_byte_array(bytes: ByteArray<T>) -> CtOption<Self>
Decode a non-zero integer from big endian bytes.
Source§impl NonZero<Limb>
impl NonZero<Limb>
Sourcepub const fn from_u8(n: NonZeroU8) -> Self
pub const fn from_u8(n: NonZeroU8) -> Self
Create a NonZero<Limb>
from a NonZeroU8
(const-friendly)
Sourcepub const fn from_u16(n: NonZeroU16) -> Self
pub const fn from_u16(n: NonZeroU16) -> Self
Create a NonZero<Limb>
from a NonZeroU16
(const-friendly)
Sourcepub const fn from_u32(n: NonZeroU32) -> Self
pub const fn from_u32(n: NonZeroU32) -> Self
Create a NonZero<Limb>
from a NonZeroU32
(const-friendly)
Sourcepub const fn from_u64(n: NonZeroU64) -> Self
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>>
impl<const LIMBS: usize> NonZero<Uint<LIMBS>>
Sourcepub const fn from_uint(n: Uint<LIMBS>) -> Self
pub const fn from_uint(n: Uint<LIMBS>) -> Self
Create a NonZero<Uint>
from a Uint
(const-friendly)
Sourcepub const fn from_u8(n: NonZeroU8) -> Self
pub const fn from_u8(n: NonZeroU8) -> Self
Create a NonZero<Uint>
from a NonZeroU8
(const-friendly)
Sourcepub const fn from_u16(n: NonZeroU16) -> Self
pub const fn from_u16(n: NonZeroU16) -> Self
Create a NonZero<Uint>
from a NonZeroU16
(const-friendly)
Sourcepub const fn from_u32(n: NonZeroU32) -> Self
pub const fn from_u32(n: NonZeroU32) -> Self
Create a NonZero<Uint>
from a NonZeroU32
(const-friendly)
Sourcepub const fn from_u64(n: NonZeroU64) -> Self
pub const fn from_u64(n: NonZeroU64) -> Self
Create a NonZero<Uint>
from a NonZeroU64
(const-friendly)
Sourcepub const fn from_u128(n: NonZeroU128) -> Self
pub const fn from_u128(n: NonZeroU128) -> Self
Create a NonZero<Uint>
from a NonZeroU128
(const-friendly)
Trait Implementations§
Source§impl<T> ConditionallySelectable for NonZero<T>where
T: ConditionallySelectable + Zero,
impl<T> ConditionallySelectable for NonZero<T>where
T: ConditionallySelectable + Zero,
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
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 moreSource§impl<T> ConstantTimeEq for NonZero<T>where
T: Zero,
impl<T> ConstantTimeEq for NonZero<T>where
T: Zero,
Source§impl<const LIMBS: usize> From<NonZero<u128>> for NonZero<Uint<LIMBS>>
impl<const LIMBS: usize> From<NonZero<u128>> for NonZero<Uint<LIMBS>>
Source§fn from(integer: NonZeroU128) -> Self
fn from(integer: NonZeroU128) -> Self
Source§impl From<NonZero<u16>> for NonZero<Limb>
impl From<NonZero<u16>> for NonZero<Limb>
Source§fn from(integer: NonZeroU16) -> Self
fn from(integer: NonZeroU16) -> Self
Source§impl<const LIMBS: usize> From<NonZero<u16>> for NonZero<Uint<LIMBS>>
impl<const LIMBS: usize> From<NonZero<u16>> for NonZero<Uint<LIMBS>>
Source§fn from(integer: NonZeroU16) -> Self
fn from(integer: NonZeroU16) -> Self
Source§impl From<NonZero<u32>> for NonZero<Limb>
impl From<NonZero<u32>> for NonZero<Limb>
Source§fn from(integer: NonZeroU32) -> Self
fn from(integer: NonZeroU32) -> Self
Source§impl<const LIMBS: usize> From<NonZero<u32>> for NonZero<Uint<LIMBS>>
impl<const LIMBS: usize> From<NonZero<u32>> for NonZero<Uint<LIMBS>>
Source§fn from(integer: NonZeroU32) -> Self
fn from(integer: NonZeroU32) -> Self
Source§impl From<NonZero<u64>> for NonZero<Limb>
impl From<NonZero<u64>> for NonZero<Limb>
Source§fn from(integer: NonZeroU64) -> Self
fn from(integer: NonZeroU64) -> Self
Source§impl<const LIMBS: usize> From<NonZero<u64>> for NonZero<Uint<LIMBS>>
impl<const LIMBS: usize> From<NonZero<u64>> for NonZero<Uint<LIMBS>>
Source§fn from(integer: NonZeroU64) -> Self
fn from(integer: NonZeroU64) -> Self
Source§impl<T: Ord + Zero> Ord for NonZero<T>
impl<T: Ord + Zero> Ord for NonZero<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd + Zero> PartialOrd for NonZero<T>
impl<T: PartialOrd + Zero> PartialOrd for NonZero<T>
Source§impl<T> Random for NonZero<T>
impl<T> Random for NonZero<T>
Source§fn random(rng: &mut impl CryptoRngCore) -> Self
fn random(rng: &mut impl CryptoRngCore) -> Self
Generate a random NonZero<T>
.
impl<T: Copy + Zero> Copy for NonZero<T>
impl<T: Eq + Zero> Eq for NonZero<T>
impl<T: Zero> StructuralPartialEq for NonZero<T>
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)