Trait big_int::BigIntBuilder
source · pub trait BigIntBuilder<const BASE: usize>where
Self: Debug,{
// Required methods
fn new() -> Self;
fn push_front(&mut self, digit: Digit);
fn push_back(&mut self, digit: Digit);
fn is_empty(&self) -> bool;
fn with_sign(self, sign: Sign) -> Self;
}
Expand description
A builder for a big int. Use this to construct a big int one digit at a time, then call .build() to finalize the builder.
You’re most likely better off using one of the From
implementations
as opposed to directly building your int via a builder.
use big_int::prelude::*;
let mut a = TightBuilder::<10>::new();
a.push_back(5);
a.push_back(3);
a.push_back(0);
a.push_back(4);
let a: Tight<10> = a.build();
assert_eq!(a, 5304.into());
Required Methods§
sourcefn new() -> Self
fn new() -> Self
Create a new builder.
use big_int::prelude::*;
let mut a = TightBuilder::<10>::new();
a.push_back(5);
assert_eq!(a.build(), 5.into());
sourcefn push_front(&mut self, digit: Digit)
fn push_front(&mut self, digit: Digit)
Push a new digit to the end of the int.
use big_int::prelude::*;
let mut a = TightBuilder::<10>::new();
a.push_back(5);
a.push_back(6);
assert_eq!(a.build(), 56.into());
sourcefn push_back(&mut self, digit: Digit)
fn push_back(&mut self, digit: Digit)
Push a new digit to the beginning of the int.
use big_int::prelude::*;
let mut a = TightBuilder::<10>::new();
a.push_front(5);
a.push_front(6);
assert_eq!(a.build(), 65.into());
Object Safety§
This trait is not object safe.