pub struct IntLit(pub I256);Expand description
An integer literal as it appears anywhere in the runtime IR.
Newtype over ethnum::I256, following the same precedent as
[moonproof_wallet::Amount] (see crates/wallet/src/types.rs):
256 bits is wide enough for any Compact Uint<128> (the largest
fixed-width unsigned type the language supports), stack-allocated
and Copy, ~2-3× the cost of i128 per arithmetic op without the
soundness gap that smaller types have for full-range u128 inputs.
The IR-emitter pass writes integer literals two ways depending on
magnitude — JSON number for values in JSON’s safe integer range
(±2^53), decimal string for anything wider so the wire format
never silently truncates a big int. The deserializer here accepts
both; the serializer emits a number if it fits in i64 and a
string otherwise (matching the emitter’s convention).
Tuple Fields§
§0: I256Implementations§
Source§impl IntLit
impl IntLit
pub const ZERO: Self
pub const ONE: Self
pub fn from_i128(v: i128) -> Self
pub fn from_u128(v: u128) -> Self
Sourcepub fn as_u128(&self) -> Option<u128>
pub fn as_u128(&self) -> Option<u128>
Try to render as a u128. Returns None if negative or > 2^128 − 1.
Trait Implementations§
impl Copy for IntLit
Source§impl<'de> Deserialize<'de> for IntLit
impl<'de> Deserialize<'de> for IntLit
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl Eq for IntLit
Source§impl Ord for IntLit
impl Ord for IntLit
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 IntLit
impl PartialOrd for IntLit
impl StructuralPartialEq for IntLit
Auto Trait Implementations§
impl Forget for IntLit
impl Freeze for IntLit
impl Move for IntLit
impl RefUnwindSafe for IntLit
impl Send for IntLit
impl Sync for IntLit
impl Unpin for IntLit
impl UnsafeUnpin for IntLit
impl UnwindSafe for IntLit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.