Skip to main content

CodeValue

Struct CodeValue 

Source
pub struct CodeValue {
    pub tag: CodeTag,
    pub heap: c_int,
    /* private fields */
}
Expand description

A value: its kind, whether it holds a counted block, and one payload the kind decides — read it through the methods (number(), len(), …), which answer 0/null for a value of another kind. ABI version 2: 16 bytes, a list’s count and keys in its block (code_abi.h’s CodeList).

Fields§

§tag: CodeTag§heap: c_int

Implementations§

Source§

impl CodeValue

Source

pub fn number(&self) -> f64

A Number’s value; 0 for anything else.

Source

pub fn str_ptr(&self) -> *const c_char

A Str’s characters; null for anything else.

Source

pub fn boolean(&self) -> c_int

A Bool’s flag; 0 for anything else.

Source

pub fn len(&self) -> i64

An Array’s or Object’s element count; 0 for anything else.

Source

pub fn is_empty(&self) -> bool

Whether len is 0.

Source

pub fn items(&self) -> *mut c_void

An Array’s or Object’s slots, for slot_at; null when it has none.

Source

pub fn keys(&self) -> *mut *const c_char

An Object’s key pointers, parallel to items; null for anything else.

Source

pub fn zeroed() -> Self

An all-zero value — tag Number, 0.0, not heap-owned. Bit-for-bit what CodeValue x = {0}; produces in C, and the required starting state before passing &mut to any constructor below (each one calls code_release on out first, exactly like the C ABI expects).

Trait Implementations§

Source§

impl Default for CodeValue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for CodeValue

Source§

impl Sync for CodeValue

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.