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.
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
otherto be stripped and have no leading zeros. - requires
selfto be stripped and have no leading zeros. - requires
otherto have at least two limbs. - requires
selfto have a greater length compared toother.
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
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>Returns the fixed encoded size of the type. Read more
Convert self to a slice and append it to the destination.
Convert self to a slice and then invoke the given closure with it.
fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usizeCalculates the encoded size. Read more
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
Auto Trait Implementations
impl RefUnwindSafe for BigUintimpl UnwindSafe for BigUintBlanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any, pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;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
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>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
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)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
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
type Output = T
type Output = TShould always be Self
The counterpart to unchecked_from.
Consume self to return an equivalent value of T.
pub fn vzip(self) -> Vimpl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode, impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode, impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode, impl<T> EncodeLike<Arc<T>> for T where
T: Encode, impl<T> EncodeLike<Rc<T>> for T where
T: Encode, impl<T> MaybeDebug for T where
T: Debug, impl<T> MaybeDebug for T where
T: Debug,