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§

source

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());
source

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());
source

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());
source

fn is_empty(&self) -> bool

Check if the builder is empty.

use big_int::prelude::*;

let mut a = TightBuilder::<10>::new();
assert!(a.is_empty());
a.push_front(5);
assert!(!a.is_empty());
source

fn with_sign(self, sign: Sign) -> Self

The builder with the given sign.

use big_int::prelude::*;

let mut a = TightBuilder::<10>::new();
a.push_back(9);
let a: Tight<10> = a.with_sign(Negative).into();
assert_eq!(a, (-9).into());

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<const BASE: usize> BigIntBuilder<BASE> for LooseBuilder<BASE>

source§

impl<const BASE: usize> BigIntBuilder<BASE> for LooseBytesBuilder<BASE>

source§

impl<const BASE: usize> BigIntBuilder<BASE> for LooseShortsBuilder<BASE>

source§

impl<const BASE: usize> BigIntBuilder<BASE> for LooseWordsBuilder<BASE>

source§

impl<const BASE: usize> BigIntBuilder<BASE> for TightBuilder<BASE>

source§

impl<const BASE: usize, B: BigIntBuilder<{ BASE }>> BigIntBuilder<BASE> for DenormalBuilder<BASE, B>