Struct u64_array_bigints_core::Uint
source · [−]Expand description
Note: LEN must satisfy LEN > 0 and LEN.checked_mul(64usize).is_some().
The construction functions and some downstream functions check for these
invariants. Users should preferrably use from_u64_array instead of direct
tuple struct construction of the Uint, because the invariants are checked
automatically by from_u64_array.
Tuple Fields
0: [u64; LEN]Implementations
sourceimpl<const LEN: usize> Uint<LEN>
impl<const LEN: usize> Uint<LEN>
These functions directly correspond to the Rust standard unsigned integers.
pub const fn from_u64_array(x: [u64; LEN]) -> Self
pub const fn to_u64_array(self) -> [u64; LEN]
pub const fn zero() -> Self
pub const fn max_value() -> Self
pub const fn one() -> Self
pub const fn is_zero(self) -> bool
pub const fn const_not(self) -> Self
pub const fn const_or(self, rhs: Self) -> Self
pub const fn const_and(self, rhs: Self) -> Self
pub const fn const_xor(self, rhs: Self) -> Self
pub const fn overflowing_add(self, rhs: Self) -> (Self, bool)
pub const fn wrapping_add(self, rhs: Self) -> Self
pub const fn checked_add(self, rhs: Self) -> Option<Self>
pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool)
pub const fn wrapping_sub(self, rhs: Self) -> Self
pub const fn checked_sub(self, rhs: Self) -> Option<Self>
pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool)
pub const fn wrapping_mul(self, rhs: Self) -> Self
pub const fn checked_mul(self, rhs: Self) -> Option<Self>
pub const fn checked_shl(self, s: usize) -> Option<Self>
pub const fn checked_shr(self, s: usize) -> Option<Self>
sourcepub const fn checked_rotl(self, s: usize) -> Option<Self>
pub const fn checked_rotl(self, s: usize) -> Option<Self>
Panics
If s >= Self::bw()
sourceimpl<const LEN: usize> Uint<LEN>
impl<const LEN: usize> Uint<LEN>
special functions
sourcepub const fn count_ones(&self) -> usize
pub const fn count_ones(&self) -> usize
Returns the number of set ones
sourcepub const fn sig_digits(&self) -> usize
pub const fn sig_digits(&self) -> usize
Returns the number of significant u64 digits
pub const fn resize_to_u64(&self) -> u64
pub const fn from_u64(x: u64) -> Self
sourcepub const fn overflowing_short_cin_mul(self, cin: u64, rhs: u64) -> (Self, u64)
pub const fn overflowing_short_cin_mul(self, cin: u64, rhs: u64) -> (Self, u64)
Returns a tuple of cin + (self * rhs) and the overflow. The
intermediates are effectively zero extended.
sourcepub const fn overflowing_short_mul_add(
self,
lhs: Self,
rhs: u64
) -> (Self, bool)
pub const fn overflowing_short_mul_add(
self,
lhs: Self,
rhs: u64
) -> (Self, bool)
Returns self + (lhs * rhs) and if overflow occured. The
intermediates are effectively zero extended.
sourcepub const fn overflowing_mul_add(self, lhs: Self, rhs: Self) -> (Self, bool)
pub const fn overflowing_mul_add(self, lhs: Self, rhs: Self) -> (Self, bool)
Returns a tuple of self + (lhs * rhs) and if overflow occured.
sourcepub const fn checked_short_divide(self, div: u64) -> Option<(Self, u64)>
pub const fn checked_short_divide(self, div: u64) -> Option<(Self, u64)>
Returns a tuple of the quotient and remainder of self divided by
div. div is zero extended. Returns None if div == 0.
sourcepub const fn panicking_short_divide(self, div: u64) -> (Self, u64)
pub const fn panicking_short_divide(self, div: u64) -> (Self, u64)
because unwrap is not const on stable, this exists for
checked_short_divide(..).unwrap()
sourcepub const fn divide(self, div: Self) -> Option<(Self, Self)>
pub const fn divide(self, div: Self) -> Option<(Self, Self)>
Divides self by div and returns a tuple of the quotient to and
remainder. Returns None if div.is_zero().
sourcepub fn rand_using<R>(rng: &mut R) -> Self where
R: RngCore,
pub fn rand_using<R>(rng: &mut R) -> Self where
R: RngCore,
Randomly-assigns self using a rand_core::RngCore random number
generator
Trait Implementations
sourceimpl<const LEN: usize> BitAndAssign<Uint<LEN>> for Uint<LEN>
impl<const LEN: usize> BitAndAssign<Uint<LEN>> for Uint<LEN>
sourcefn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the &= operation. Read more
sourceimpl<const LEN: usize> BitOrAssign<Uint<LEN>> for Uint<LEN>
impl<const LEN: usize> BitOrAssign<Uint<LEN>> for Uint<LEN>
sourcefn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the |= operation. Read more
sourceimpl<const LEN: usize> BitXorAssign<Uint<LEN>> for Uint<LEN>
impl<const LEN: usize> BitXorAssign<Uint<LEN>> for Uint<LEN>
sourcefn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the ^= operation. Read more
sourceimpl<const LEN: usize> Ord for Uint<LEN>
impl<const LEN: usize> Ord for Uint<LEN>
sourceimpl<const LEN: usize> PartialOrd<Uint<LEN>> for Uint<LEN>
impl<const LEN: usize> PartialOrd<Uint<LEN>> for Uint<LEN>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
impl<const LEN: usize> Copy for Uint<LEN>
impl<const LEN: usize> Eq for Uint<LEN>
impl<const LEN: usize> StructuralEq for Uint<LEN>
impl<const LEN: usize> StructuralPartialEq for Uint<LEN>
Auto Trait Implementations
impl<const LEN: usize> RefUnwindSafe for Uint<LEN>
impl<const LEN: usize> Send for Uint<LEN>
impl<const LEN: usize> Sync for Uint<LEN>
impl<const LEN: usize> Unpin for Uint<LEN>
impl<const LEN: usize> UnwindSafe for Uint<LEN>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more