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 .into() to construct the final int.
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.into();
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();
unsafe {
a.push_back(5);
}
let a: Tight<10> = a.into();
assert_eq!(a, 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);
let a: Tight<10> = a.into();
assert_eq!(a, 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);
let a: Tight<10> = a.into();
assert_eq!(a, 65.into());
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.