#[repr(C)]pub struct TypedScalar {
pub kind: ScalarKind,
pub payload_lo: u64,
pub payload_hi: u64,
}Expand description
Type-preserving scalar value for VM↔JIT boundary exchange.
Carries an explicit type discriminator (kind) so that integer 42 and
float 42.0 are distinguishable even when their f64 bit patterns would
be identical.
payload_hi is zero for all types smaller than 128 bits.
Fields§
§kind: ScalarKind§payload_lo: u64§payload_hi: u64Second 64-bit word — only used for I128/U128. Zero otherwise.
Implementations§
Source§impl TypedScalar
impl TypedScalar
Sourcepub fn f64_from_bits(bits: u64) -> Self
pub fn f64_from_bits(bits: u64) -> Self
Create an F64 scalar from raw bits.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Extract as i64 (only valid if kind is an integer type).
Returns None for U64 values > i64::MAX (use as_u64() instead).
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Extract as u64 (only valid if kind is an unsigned integer type).
Sourcepub fn to_f64_lossy(&self) -> Option<f64>
pub fn to_f64_lossy(&self) -> Option<f64>
Interpret this scalar as an f64 regardless of kind (for numeric comparison). Integer kinds are cast; float kinds use their stored value; non-numeric returns None.
Trait Implementations§
Source§impl Clone for TypedScalar
impl Clone for TypedScalar
Source§fn clone(&self) -> TypedScalar
fn clone(&self) -> TypedScalar
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TypedScalar
impl Debug for TypedScalar
Source§impl PartialEq for TypedScalar
impl PartialEq for TypedScalar
impl Copy for TypedScalar
impl StructuralPartialEq for TypedScalar
Auto Trait Implementations§
impl Freeze for TypedScalar
impl RefUnwindSafe for TypedScalar
impl Send for TypedScalar
impl Sync for TypedScalar
impl Unpin for TypedScalar
impl UnsafeUnpin for TypedScalar
impl UnwindSafe for TypedScalar
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