pub struct Int(/* private fields */);Expand description
An integer, with no bound.
Addition, subtraction, multiplication and negation are exact and never
fault. Integer division rounds toward negative infinity and % is the
matching remainder, so for every nonzero b,
a == a.div(b) * b + a.rem(b) with the remainder zero or carrying b’s
sign. A zero divisor is the one fault.
The derived order is the order of the numbers, which is data.md’s.
Implementations§
Source§impl Int
impl Int
Sourcepub fn from_limbs(limbs: &[u32]) -> Int
pub fn from_limbs(limbs: &[u32]) -> Int
Returns the nonnegative integer whose magnitude is limbs,
little-endian base 2^32: what a decoded literal holds, read in
O(limbs).
Sourcepub fn parse(digits: &str) -> Option<Int>
pub fn parse(digits: &str) -> Option<Int>
Returns the integer ASCII decimal digits with an optional leading -
spell. +, separators, whitespace and other radixes are refused.
Sourcepub fn div(&self, divisor: &Int) -> Result<Int, Fault>
pub fn div(&self, divisor: &Int) -> Result<Int, Fault>
Returns self.div(divisor): the quotient rounded toward negative
infinity.
§Errors
Fault::DivisionByZero for a zero divisor.
Sourcepub fn rem(&self, divisor: &Int) -> Result<Int, Fault>
pub fn rem(&self, divisor: &Int) -> Result<Int, Fault>
Returns self % divisor: the remainder matching Int::div, zero or
carrying the divisor’s sign.
§Errors
Fault::DivisionByZero for a zero divisor.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns whether this is below zero.
Sourcepub fn bits(&self) -> u64
pub fn bits(&self) -> u64
Returns how many bits the magnitude takes, the sign excluded: 0 for
zero, 1 for 1 and -1, and 4096 for 2^4096 - 1.
Sourcepub fn to_index(&self) -> Option<usize>
pub fn to_index(&self) -> Option<usize>
Returns this as a zero-based position, or None for a negative one or
one no in-memory sequence could reach.
Sourcepub fn from_count(count: usize) -> Int
pub fn from_count(count: usize) -> Int
Returns a count — a length or a position — as an integer.
Trait Implementations§
Source§impl Display for Int
The text form: decimal digits, - before a negative number, no leading
zero (data.md, Int).
impl Display for Int
The text form: decimal digits, - before a negative number, no leading
zero (data.md, Int).
impl Eq for Int
Source§impl Ord for Int
impl Ord for Int
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Int
impl PartialOrd for Int
Source§impl Shaped for Int
impl Shaped for Int
Source§fn write_at(
&self,
out: &mut ValueWriter<'_, '_>,
ty: &Type,
) -> Result<(), EncodeError>
fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>
Source§fn read_at(
input: &mut ValueReader<'_, '_, '_>,
ty: &Type,
) -> Result<Int, DecodeError>
fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Int, DecodeError>
impl StructuralPartialEq for Int
Source§impl Wire for Int
impl Wire for Int
Source§fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)
fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)
out, and pushes
its parts to parts in the order they are written after them.Source§fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>
fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>
reader: the value itself when it has no parts,
else its parts to read and what joins them. Read moreSource§fn write(&self, out: &mut Vec<u8>)
fn write(&self, out: &mut Vec<u8>)
out: its head, and then each part’s bytes in
order, written over a stack on the heap, so a value nested however
deep is written on a native stack of fixed size.Auto Trait Implementations§
impl Forget for Int
impl Freeze for Int
impl Move for Int
impl RefUnwindSafe for Int
impl Send for Intwhere
RawVecInner: Send,
impl Sync for Intwhere
RawVecInner: Sync,
impl Unpin for Int
impl UnsafeUnpin for Int
impl UnwindSafe for Intwhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> AnyWire for Twhere
T: Wire,
impl<T> AnyWire for Twhere
T: Wire,
Source§fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)
fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)
Wire::write_head.