pub struct Packed(/* private fields */);Expand description
The packed integer, exactly. Most versions fit u128; a major of 2^80 or
more does not, and the canonical dump writes the exact integer. Ordered,
compared and hashed as Python’s int (implemented by the scaffold).
The representation is private and always canonical: a value below 2^128
is held as a u128, and a larger one as little-endian limbs with a
non-zero top limb. So Packed::from_limbs of a value written with
leading zero limbs (a 4,300-digit group of leading zeros, sized from its
digit count) equals, hashes and orders as the same value from
Packed::from_u128.
Implementations§
Source§impl Packed
impl Packed
Sourcepub fn from_limbs(limbs: &[u64]) -> Self
pub fn from_limbs(limbs: &[u64]) -> Self
The value of little-endian u64 limbs, any number of them, leading
(most significant) zero limbs included.
Sourcepub fn big_limbs(&self) -> Option<&[u64]>
pub fn big_limbs(&self) -> Option<&[u64]>
The limbs of a value of 2^128 or more, borrowed: little-endian, the
last one non-zero, at most super::MAX_LIMBS for a version a
parse packed. None below 2^128, where Self::as_u128 is the
value. Unlike Self::to_limbs it copies nothing, so a writer of
an input’s version needs no heap for it
(unityrs_dump::json::write_packed).
Sourcepub fn to_limbs(&self) -> Vec<u64>
pub fn to_limbs(&self) -> Vec<u64>
The value as little-endian u64 limbs, without leading zero limbs
(empty for 0).
Sourcepub fn heap_bytes(&self) -> usize
pub fn heap_bytes(&self) -> usize
The heap bytes the value owns (0 below 2^128).