Struct sp_runtime::biguint::BigUint[][src]

pub struct BigUint { /* fields omitted */ }
Expand description

Simple wrapper around an infinitely large integer, represented as limbs of Single.

Implementations

Create a new instance with size limbs. This prevents any number with zero limbs to be created.

The behavior of the type is undefined with zero limbs.

Raw constructor from custom limbs. If limbs is empty, Zero::zero() implementation is used.

Number of limbs.

A naive getter for limb at index. Note that the order is lsb -> msb.

Panics

This panics if index is out of range.

A naive getter for limb at index. Note that the order is lsb -> msb.

A naive setter for limb at index. Note that the order is lsb -> msb.

Panics

This panics if index is out of range.

returns the least significant limb of the number.

Panics

While the constructor of the type prevents this, this can panic if self has no digits.

returns the most significant limb of the number.

Panics

While the constructor of the type prevents this, this can panic if self has no digits.

Strips zeros from the left side (the most significant limbs) of self, if any.

Zero-pad self from left to reach size limbs. Will not make any difference if self is already bigger than size limbs.

Adds self with other. self and other do not have to have any particular size. Given that the n = max{size(self), size(other)}, it will produce a number with n + 1 limbs.

This function does not strip the output and returns the original allocated n + 1 limbs. The caller may strip the output if desired.

Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.

Subtracts other from self. self and other do not have to have any particular size. Given that the n = max{size(self), size(other)}, it will produce a number of size n.

If other is bigger than self, Err(B - borrow) is returned.

Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.

Multiplies n-limb number self with m-limb number other.

The resulting number will always have n + m limbs.

This function does not strip the output and returns the original allocated n + m limbs. The caller may strip the output if desired.

Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.

Divides self by a single limb other. This can be used in cases where the original division cannot work due to the divisor (other) being just one limb.

Invariant: other cannot be zero.

Divides an n + m limb self by a n limb other. The result is a m + 1 limb quotient and a n limb remainder, if enabled by passing true in rem argument, both in the form of an option’s Ok.

  • requires other to be stripped and have no leading zeros.
  • requires self to be stripped and have no leading zeros.
  • requires other to have at least two limbs.
  • requires self to have a greater length compared to other.

All arguments are examined without being stripped for the above conditions. If any of the above fails, None is returned.`

Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Attempt to deserialise the value from input.

Attempt to skip the encoded value from input. Read more

Returns the fixed encoded size of the type. Read more

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

Convert self to a slice and append it to the destination.

Convert self to an owned vector.

Convert self to a slice and then invoke the given closure with it.

If possible give a hint of expected size of the encoding. Read more

Calculates the encoded size. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The resulting type after applying the * operator.

Performs the * operation. Read more

Returns the multiplicative identity element of Self, 1. Read more

Sets self to the multiplicative identity element of Self, 1.

Returns true if self is equal to the multiplicative identity. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Returns the additive identity element of Self, 0. Read more

Returns true if self is equal to the additive identity.

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

True iff no bits are set.

Return the value of Self that is clear.

Decode Self and consume all of the given input data. Read more

Decode Self and consume all of the given input data. Read more

Decode Self with the given maximum recursion depth. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Return an encoding of Self prepended by given slice.

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The counterpart to unchecked_from.

Consume self to return an equivalent value of T.