pub struct BigInt {
sign: Sign,
val: u128,
}
Expand description
A signed integer in the range [-2^128, 2^128], represented by a u128
and an explicit sign.
In the logic, we work mathematical integers so we could represent them with arbitrary precision
integers. We instead take the simpler approach of using a fixed size representation that allows
us to store any Rust literal, i.e., we can represent both i128::MIN
and u128::MAX
. This works
because we never do arithmetic. We can change the representation in the future (and use arbitrary
precision integers) if this ever becomes a problem, e.g., if we want to do (precise) arithmetic
during constant folding.
Fields§
§sign: Sign
§val: u128
Implementations§
Source§impl BigInt
impl BigInt
pub const ZERO: BigInt = _
pub const ONE: BigInt = _
Sourcepub fn int_min(bit_width: u32) -> BigInt
pub fn int_min(bit_width: u32) -> BigInt
Given the bit width of a signed integer type, produces the minimum integer for that type, i.e., -2^(bit_width - 1).
Trait Implementations§
Source§impl<__D: SpanDecoder> Decodable<__D> for BigInt
impl<__D: SpanDecoder> Decodable<__D> for BigInt
Source§impl FixpointFmt for BigInt
impl FixpointFmt for BigInt
Source§impl Ord for BigInt
impl Ord for BigInt
Source§impl PartialOrd for BigInt
impl PartialOrd for BigInt
impl Copy for BigInt
impl Eq for BigInt
impl StructuralPartialEq for BigInt
Auto Trait Implementations§
impl Freeze for BigInt
impl RefUnwindSafe for BigInt
impl Send for BigInt
impl Sync for BigInt
impl Unpin for BigInt
impl UnwindSafe for BigInt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more