pub struct BoxedUint { /* private fields */ }
Available on crate feature alloc only.
Expand description

Fixed-precision heap-allocated big unsigned integer.

Alternative to the stack-allocated Uint but with a fixed precision chosen at runtime instead of compile time.

Unlike many other heap-allocated big integer libraries, this type is not arbitrary precision and will wrap at its fixed-precision rather than automatically growing.

Implementations§

source§

impl BoxedUint

source

pub fn adc(&self, rhs: &Self, carry: Limb) -> (Self, Limb)

Computes a + b + carry, returning the result along with the new carry.

source

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

Perform wrapping addition, discarding overflow.

source§

impl BoxedUint

source

pub fn zero() -> Self

Get the value 0, represented as succinctly as possible.

source

pub fn one() -> Self

Get the value 1, represented as succinctly as possible.

source

pub fn new(bits_precision: usize) -> Option<Self>

Create a new BoxedUint with the given number of bits of precision.

Returns None if the number of bits is not a multiple of the Limb size.

source

pub fn max(bits_precision: usize) -> Option<Self>

Get the maximum value for a given number of bits of precision.

Returns None if the number of bits is not a multiple of the Limb size.

source

pub fn from_words(words: &[Word]) -> Self

Create a BoxedUint from an array of Words (i.e. word-sized unsigned integers).

source

pub fn to_words(&self) -> Vec<Word>

Create an array of Words (i.e. word-sized unsigned integers) from a BoxedUint.

source

pub fn as_words(&self) -> &[Word]

Borrow the inner limbs as a slice of Words.

source

pub fn as_words_mut(&mut self) -> &mut [Word]

Borrow the inner limbs as a mutable array of Words.

source

pub fn as_limbs(&self) -> &[Limb]

Borrow the limbs of this BoxedUint.

source

pub fn as_limbs_mut(&mut self) -> &mut [Limb]

Borrow the limbs of this BoxedUint mutably.

source

pub fn to_limbs(&self) -> Vec<Limb>

Convert this BoxedUint into its inner limbs.

source

pub fn into_limbs(self) -> Vec<Limb>

Convert this BoxedUint into its inner limbs.

source

pub fn bits(&self) -> usize

Get the precision of this BoxedUint in bits.

Trait Implementations§

source§

impl AsMut<[Limb]> for BoxedUint

source§

fn as_mut(&mut self) -> &mut [Limb]

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

impl AsMut<[u64]> for BoxedUint

source§

fn as_mut(&mut self) -> &mut [Word]

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

impl AsRef<[Limb]> for BoxedUint

source§

fn as_ref(&self) -> &[Limb]

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

impl AsRef<[u64]> for BoxedUint

source§

fn as_ref(&self) -> &[Word]

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

impl CheckedAdd<&BoxedUint> for BoxedUint

§

type Output = BoxedUint

Output type.
source§

fn checked_add(&self, rhs: &Self) -> CtOption<Self>

Perform checked subtraction, returning a CtOption which is_some only if the operation did not overflow.
source§

impl Clone for BoxedUint

source§

fn clone(&self) -> BoxedUint

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 ConstantTimeEq for BoxedUint

source§

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

Determine if two items are equal. Read more
source§

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

Determine if two items are NOT equal. Read more
source§

impl Debug for BoxedUint

source§

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

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

impl Default for BoxedUint

source§

fn default() -> BoxedUint

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

impl Display for BoxedUint

source§

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

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

impl LowerHex for BoxedUint

source§

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

Formats the value using the given formatter.
source§

impl PartialEq for BoxedUint

source§

fn eq(&self, other: &Self) -> 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 UpperHex for BoxedUint

source§

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

Formats the value using the given formatter.
source§

impl Zeroize for BoxedUint

Available on crate feature zeroize only.
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.
source§

impl Eq for BoxedUint

Auto Trait Implementations§

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 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.