Skip to main content

Value

Struct Value 

Source
pub struct Value(/* private fields */);
Expand description

A NaN-boxed JavaScript value. ABI-identical to a u64, so *mut Value arrays and Completion fields carry it with no wrapping.

Implementations§

Source§

impl Value

Source

pub const CANON_NAN: u64 = CANON_NAN

The canonical positive quiet NaN, 0x7ff8_0000_0000_0000.

Source

pub const UNDEFINED: Value

undefined.

Source

pub const NULL: Value

null.

Source

pub const HOLE: Value

The array/TDZ hole.

Source

pub const UNINITIALIZED: Value

The uninitialized register-slot sentinel written by the frame prologue.

Source

pub const FALSE: Value

false.

Source

pub const TRUE: Value

true.

Source

pub const fn boolean(value: bool) -> Value

Boxes a boolean (boolPayload).

Source

pub const fn int32(value: u32) -> Value

Boxes a 32-bit integer (int32Payload, upper half zero).

Source

pub const fn heap_ref(id: SlotId) -> Value

Boxes a validated heap reference (packSlot).

Source

pub fn number(value: f64) -> Value

Encodes a double. Every NaN is canonicalized to CANON_NAN, so the result never collides with the boxed range (canonicalizeNaN).

Source

pub const fn from_bits(bits: u64) -> Value

Reinterprets a raw 64-bit ABI word as a Value. The wire word is taken verbatim; use Value::decode to interpret it.

Source

pub const fn to_bits(self) -> u64

The raw 64-bit ABI word.

Source

pub const fn is_number(self) -> bool

Whether the word is a non-boxed arithmetic double.

Source

pub const fn is_uninitialized(self) -> bool

Whether the word is exactly the uninitialized sentinel. This is the hot check the frame prologue and GC scan rely on.

Source

pub const fn decode(self) -> Option<Decoded>

Interprets the word per the tag-specific payload rules (decode). Returns None for a boxed word whose payload is malformed for its tag.

Source

pub fn as_f64(self) -> Option<f64>

The double value, when the word is a non-boxed number.

Source

pub const fn as_int32(self) -> Option<u32>

The integer, when the word is a well-formed boxed int32.

Source

pub const fn as_bool(self) -> Option<bool>

The boolean, when the word is a well-formed boxed boolean.

Source

pub const fn as_heap_ref(self) -> Option<SlotId>

The heap slot, when the word is a well-formed boxed reference.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Value

Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Value

Source§

impl Hash for Value

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.