Skip to main content

Uint

Struct Uint 

Source
pub struct Uint<const BITS: usize, const LIMBS: usize> {
    pub limbs: [u64; LIMBS],
}
Expand description

A fixed-size unsigned integer of BITS bits stored in LIMBS 64-bit limbs.

LIMBS must be ceil(BITS / 64) (checked at compile time). Values are little-endian. When BITS is not a multiple of 64 the caller must keep the unused high bits of the top limb zero; the decoding helpers do this automatically but Uint::from_limbs does not.

Fields§

§limbs: [u64; LIMBS]

Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS>

Source

pub const ZERO: Self

Source

pub const ONE: Self

Source

pub const MAX: Self

Source

pub const fn from_limbs(limbs: [u64; LIMBS]) -> Self

Builds a value directly from its little-endian limbs.

This is a low-level escape hatch: when BITS is not a multiple of 64 the caller is responsible for ensuring the unused high bits of the top limb are zero. The decoding helpers (Self::from_be_slice, Self::from_le_slice, Self::from_str_radix) enforce this for you.

Source

pub const fn from_u64(v: u64) -> Self

Builds a value from a u64.

Source

pub fn from_be_slice(bytes: &[u8]) -> Self

Decodes LIMBS * 8 big-endian bytes.

The expected byte length is the limb-aligned width ceil(BITS / 64) * 8 bytes, which equals BITS / 8 whenever BITS is a multiple of 64. Any bits at or above BITS are cleared.

§Panics

Panics if bytes.len() != LIMBS * 8.

Source

pub fn from_le_slice(bytes: &[u8]) -> Self

Decodes LIMBS * 8 little-endian bytes.

The expected byte length is the limb-aligned width ceil(BITS / 64) * 8 bytes, which equals BITS / 8 whenever BITS is a multiple of 64. Any bits at or above BITS are cleared.

§Panics

Panics if bytes.len() != LIMBS * 8.

Source

pub fn to_be_bytes(&self) -> Vec<u8> ⓘ

Encodes the value as LIMBS * 8 big-endian bytes.

Allocates a Vec. Prefer Self::to_be_bytes_fixed in allocation-free contexts.

Source

pub fn to_le_bytes(&self) -> Vec<u8> ⓘ

Encodes the value as LIMBS * 8 little-endian bytes.

Allocates a Vec. Prefer Self::to_le_bytes_fixed in allocation-free contexts.

Source

pub fn to_be_bytes_fixed<const N: usize>(&self) -> [u8; N]

Encodes the value as N big-endian bytes.

§Panics

Panics if N != LIMBS * 8.

Source

pub fn to_le_bytes_fixed<const N: usize>(&self) -> [u8; N]

Encodes the value as N little-endian bytes.

§Panics

Panics if N != LIMBS * 8.

Source

pub fn bit(&self, index: usize) -> bool

Returns bit index (0 is the least significant).

Returns false for any index >= BITS.

Source

pub fn is_zero(&self) -> bool

Returns true when the value is zero.

Source

pub fn bit_len(&self) -> usize

Position of the highest set bit, plus one. Returns 0 for zero.

Source

pub fn is_odd(&self) -> bool

Returns true when the value is odd.

Source

pub fn ct_ge(&self, rhs: &Self) -> bool

Constant-time self >= rhs.

The execution path does not depend on the operand values.

Source

pub fn ct_eq(&self, rhs: &Self) -> bool

Constant-time self == rhs.

Source

pub fn ct_select(a: &Self, b: &Self, choice: bool) -> Self

Constant-time select: returns *a if choice is true, else *b.

Source

pub fn add_raw(&self, rhs: &Self) -> (Self, u64)

Adds with carry, returning the wrapped sum and the carry out (0 or 1).

Source

pub fn sub_raw(&self, rhs: &Self) -> (Self, u64)

Subtracts with borrow, returning the wrapped difference and the borrow out (0 or 1).

Source

pub fn add_mod(&self, rhs: &Self, modulus: &Self) -> Self

(self + rhs) mod modulus, constant time.

Requires self < modulus and rhs < modulus, and modulus > 0.

Source

pub fn sub_mod(&self, rhs: &Self, modulus: &Self) -> Self

(self - rhs) mod modulus, constant time.

Requires self < modulus, rhs < modulus, and modulus > 0. For self < rhs the result wraps to modulus - (rhs - self).

Source

pub fn double_mod(&self, modulus: &Self) -> Self

(self + self) mod modulus, constant time.

Requires self < modulus and modulus > 0.

Source

pub fn mul_mod(&self, rhs: &Self, modulus: &Self) -> Self

(self * rhs) mod modulus using a bit-serial (shift-and-subtract) reduction.

Constant time in the operands. Requires modulus > 0 and that the wide product fits in 2 * LIMBS limbs (always true). This is the reference implementation; prefer Self::mul_mod_barrett in hot loops.

Source

pub fn compute_mu_for_barrett(&self) -> [u64; 260]

Computes mu = floor(2^(2 * eff_limbs * 64) / self) for Barrett reduction, where eff_limbs is ceil(self.bit_len() / 64).

Pass the result to Self::modpow_barrett or Self::mul_mod_barrett_eff. The value is produced for the modulus’s own effective limb count, which is what those functions use.

§Panics

Panics when self is zero (the reciprocal is undefined).

Source

pub fn modpow_barrett(&self, exp: &Self, modulus: &Self, mu: &[u64]) -> Self

self^exp mod modulus using Barrett reduction.

mu must be produced by Self::compute_mu_for_barrett for the same modulus; the effective limb count is derived from modulus.bit_len(). The base is reduced internally, so any input is accepted.

Not constant time in exp (it branches on each exponent bit); only use it with a public exponent.

§Panics

Panics when modulus is zero or its effective limb count exceeds MAX_BARRETT_LIMBS.

Source

pub fn modpow_barrett_eff( &self, exp: &Self, modulus: &Self, mu: &[u64], eff_limbs: usize, ) -> Self

Barrett modular exponentiation with an explicit effective limb count.

eff_limbs must equal ceil(modulus.bit_len() / 64) and mu must be the matching reciprocal. See Self::modpow_barrett for the other requirements.

Source

pub fn modpow_barrett_w<const W: usize>( &self, exp: &Self, modulus: &Self, mu: &[u64], ) -> Self

Barrett modular exponentiation with a caller-chosen working width W.

W must be at least 2 * (eff_limbs + 1), where eff_limbs is the modulus’s effective limb count. A W near that lower bound keeps the scratch buffers small and is significantly faster than the default Self::modpow_barrett (which uses W = MAX_LIMBS). Callers should pick W from the modulus size; see the RSA public-key code.

Source

pub fn mul_mod_barrett(&self, rhs: &Self, modulus: &Self, mu: &[u64]) -> Self

(self * rhs) mod modulus using Barrett reduction.

mu must be produced by Self::compute_mu_for_barrett for the same modulus. Both operands must already be reduced (< 2^(eff*64), in practice < modulus); passing unreduced operands yields silently wrong results. The effective limb count is derived from modulus.bit_len().

§Panics

Panics under the same conditions as Self::reduce_wide_barrett_eff.

Source

pub fn mul_mod_barrett_eff( &self, rhs: &Self, modulus: &Self, mu: &[u64], eff_limbs: usize, ) -> Self

Barrett multiplication with an explicit effective limb count.

eff_limbs must equal ceil(modulus.bit_len() / 64) and both operands must already be reduced. See Self::mul_mod_barrett.

Source

pub fn mul_mod_barrett_w<const W: usize>( &self, rhs: &Self, modulus: &Self, mu: &[u64], ) -> Self

Barrett multiplication with a caller-chosen working width W.

W must be at least 2 * (eff_limbs + 1) where eff_limbs is the modulus’s effective limb count. Picking W near that bound (instead of the default MAX_LIMBS) makes this much faster; see Self::modpow_barrett_w.

The operands must already be reduced below the modulus.

Source

pub fn reduce_wide_barrett_eff( product: &[u64; 260], modulus: &Self, mu: &[u64], eff_limbs: usize, ) -> Self

Barrett reduction of a 2 * LIMBS-wide product with an explicit effective limb count k = eff_limbs.

mu must equal floor(2^(2 * k * 64) / modulus) — that is, the value returned by Self::compute_mu_for_barrett for this modulus — and have at least k + 1 entries. The product must be less than 2^(2 * k * 64); when k < LIMBS this means the factors of the product must already be reduced (see Self::mul_mod_barrett_eff).

§Panics

Panics when eff_limbs is out of range, when the effective width does not fit in MAX_LIMBS, or when mu is too short.

Source

pub fn modpow(&self, exp: &Self, modulus: &Self) -> Self

self^exp mod modulus using square-and-multiply, scanning only up to the exponent’s bit length.

Uses the bit-serial Self::mul_mod reduction and is therefore slow; prefer Self::modpow_barrett in hot loops.

Not constant time in exp (it branches on each exponent bit); only use it with a public exponent.

§Panics

In debug builds modulus must be nonzero; in release a zero modulus yields an unreduced result.

Source

pub fn reduce_wide_barrett( product: &[u64; 260], modulus: &Self, mu: &[u64], ) -> Self

Barrett reduction of a 2 * LIMBS-wide product modulo modulus.

The effective limb count is derived from modulus.bit_len(), so mu must be the matching value from Self::compute_mu_for_barrett. The product must be less than 2^(2 * k * 64), where k is that effective limb count; when the modulus does not fill all LIMBS limbs this means the product’s factors must already be reduced (see Self::mul_mod_barrett).

Equivalent to Self::reduce_wide_barrett_eff with k = ceil(modulus.bit_len() / 64).

Source

pub fn add_word(&self, word: u64) -> (Self, u64)

Adds a single u64, returning the wrapped result and carry out.

Source

pub fn sub_word(&self, word: u64) -> (Self, u64)

Subtracts a single u64, returning the wrapped result and borrow out.

Source

pub fn mul_word(&self, word: u64) -> (Self, u64)

Multiplies by a single u64, returning the low LIMBS limbs and the carry (high word) out.

Source

pub fn div_rem_word(&self, word: u64) -> (Self, u64)

Divides by a single u64, returning the quotient and remainder.

§Panics

Panics if word is zero.

Source

pub fn add_u128(&self, value: u128) -> Self

Adds a u128, wrapping on overflow.

Source

pub fn sub_u128(&self, value: u128) -> Self

Subtracts a u128, wrapping on underflow.

Source

pub fn mul_u128(&self, value: u128) -> Self

Multiplies by a u128, returning the low BITS bits (wrapping).

Source

pub fn div_rem_u128(&self, divisor: u128) -> (Self, u128)

Divides by a u128, returning the quotient and remainder.

§Panics

Panics if divisor is zero.

Source

pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, Error>

Parses src as an unsigned integer in radix (2..=36), accepting the ASCII digits 0-9, a-z and A-Z.

Leading zero digits are accepted. The value must fit in BITS bits, otherwise Error::Overflow is returned. Signs (+/-), whitespace, _ separators and prefixes such as 0x are not accepted. The input length is bounded before any per-digit work, so a hostile multi-megabyte string cannot force unbounded computation. This method never allocates.

§Errors

Returns Error::InvalidRadix for radix outside 2..=36, Error::EmptyString for an empty input, Error::InvalidDigit for a non-digit or out-of-range character, and Error::Overflow when the value does not fit in BITS bits.

§Examples
use big_number::Uint;
let max = Uint::<64, 1>::from_str_radix("ffffffffffffffff", 16).unwrap();
assert_eq!(max, Uint::<64, 1>::MAX);
assert!(Uint::<64, 1>::from_str_radix("10000000000000000", 16).is_err()); // 2^64
Source

pub fn to_string_radix(&self, radix: u32) -> String

Formats the value in radix (2..=36) using lowercase digits.

Allocates a single String.

§Panics

Panics if radix is outside 2..=36.

Trait Implementations§

Source§

impl<const BITS: usize, const LIMBS: usize> Add for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i8) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i16) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i64) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i128) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u8) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u16) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Add<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: u128) -> Self::Output

Performs the + operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Clone for Uint<BITS, LIMBS>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Copy for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Debug for Uint<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Display for Uint<BITS, LIMBS>

Available on crate feature alloc only.
Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Div<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i8) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i16) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i128) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u8) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u16) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Div<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u128) -> Self::Output

Performs the / operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Eq for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> LowerHex for Uint<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Mul for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i128) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Mul<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u128) -> Self::Output

Performs the * operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> PartialEq for Uint<BITS, LIMBS>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i8> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i8) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i16> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i16) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i32> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i32) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i64> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i64) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<i128> for Uint<BITS, LIMBS>

Source§

type Output = u128

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i128) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u8> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u8) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u16> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u16) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u32> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u32) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u64> for Uint<BITS, LIMBS>

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Rem<u128> for Uint<BITS, LIMBS>

Source§

type Output = u128

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u128) -> Self::Output

Performs the % operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> StructuralPartialEq for Uint<BITS, LIMBS>

Source§

impl<const BITS: usize, const LIMBS: usize> Sub for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i8) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i16) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i64) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<i128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i128) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u8> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u8) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u16> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u16) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u32> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u32) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u64> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u64) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> Sub<u128> for Uint<BITS, LIMBS>

Source§

type Output = Uint<BITS, LIMBS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: u128) -> Self::Output

Performs the - operation. Read more
Source§

impl<const BITS: usize, const LIMBS: usize> UpperHex for Uint<BITS, LIMBS>

Source§

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

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

impl<const BITS: usize, const LIMBS: usize> Zeroize for Uint<BITS, LIMBS>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl<const BITS: usize, const LIMBS: usize> Freeze for Uint<BITS, LIMBS>
where [u64; LIMBS]: Freeze,

§

impl<const BITS: usize, const LIMBS: usize> RefUnwindSafe for Uint<BITS, LIMBS>

§

impl<const BITS: usize, const LIMBS: usize> Send for Uint<BITS, LIMBS>
where [u64; LIMBS]: Send,

§

impl<const BITS: usize, const LIMBS: usize> Sync for Uint<BITS, LIMBS>
where [u64; LIMBS]: Sync,

§

impl<const BITS: usize, const LIMBS: usize> Unpin for Uint<BITS, LIMBS>
where [u64; LIMBS]: Unpin,

§

impl<const BITS: usize, const LIMBS: usize> UnsafeUnpin for Uint<BITS, LIMBS>
where [u64; LIMBS]: UnsafeUnpin,

§

impl<const BITS: usize, const LIMBS: usize> UnwindSafe for Uint<BITS, LIMBS>
where [u64; LIMBS]: UnwindSafe,

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> 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<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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.