Skip to main content

Module extraction

Module extraction 

Source
Expand description

Centralized extraction helpers for ValueWord values.

These require_* functions provide a single source of truth for extracting typed values from ValueWord, returning descriptive VMError on type mismatch. They replace scattered ad-hoc patterns like:

let s = nb.as_str()
    .ok_or_else(|| VMError::TypeError { expected: "string", got: "other" })?;

Functions§

nb_to_display_string
Convert a ValueWord to a display string.
require_arc_string
Extract an Arc reference from a ValueWord, or return a type error.
require_array
Extract an array view from a ValueWord, or return a type error.
require_bool
Extract a bool from a ValueWord, or return a type error.
require_closure
Extract Closure fields (function_id, upvalues) from a ValueWord, or return a type error.
require_datatable
Extract a DataTable reference from a ValueWord, or return a type error.
require_f64
Extract an f64 from a ValueWord, or return a type error.
require_int
Extract an i64 from a ValueWord, or return a type error.
require_number
Extract a number (f64 or i64 coerced to f64) from a ValueWord, or return a type error.
require_string
Extract a string reference from a ValueWord, or return a type error.
require_typed_object
Extract TypedObject fields (schema_id, slots, heap_mask) from a ValueWord, or return a type error.