pub struct NanBoxedValue(/* private fields */);Expand description
An 8-byte NaN-boxed value
This is the core type for the NaN-boxing optimization. All Seq values are encoded into exactly 8 bytes.
Implementations§
Source§impl NanBoxedValue
impl NanBoxedValue
Sourcepub fn is_variant(self) -> bool
pub fn is_variant(self) -> bool
Check if this is a Variant
Sourcepub fn is_quotation(self) -> bool
pub fn is_quotation(self) -> bool
Check if this is a Quotation
Sourcepub fn is_closure(self) -> bool
pub fn is_closure(self) -> bool
Check if this is a Closure
Sourcepub fn is_channel(self) -> bool
pub fn is_channel(self) -> bool
Check if this is a Channel
Sourcepub fn is_weave_ctx(self) -> bool
pub fn is_weave_ctx(self) -> bool
Check if this is a WeaveCtx
Sourcepub fn from_float(f: f64) -> Self
pub fn from_float(f: f64) -> Self
Create a NaN-boxed float
If the float is NaN, it’s canonicalized to avoid collision with boxed values.
Sourcepub fn try_from_int(n: i64) -> Option<Self>
pub fn try_from_int(n: i64) -> Option<Self>
Create a NaN-boxed integer, returning None if out of range
Sourcepub fn from_string_ptr(ptr: *const SeqString) -> Self
pub fn from_string_ptr(ptr: *const SeqString) -> Self
Sourcepub fn from_symbol_ptr(ptr: *const SeqString) -> Self
pub fn from_symbol_ptr(ptr: *const SeqString) -> Self
Sourcepub fn from_variant_ptr(ptr: *const Arc<VariantData>) -> Self
pub fn from_variant_ptr(ptr: *const Arc<VariantData>) -> Self
Create a NaN-boxed variant pointer
Sourcepub fn from_map_ptr(ptr: *const Box<HashMap<MapKey, Value>>) -> Self
pub fn from_map_ptr(ptr: *const Box<HashMap<MapKey, Value>>) -> Self
Create a NaN-boxed map pointer
Sourcepub fn from_quotation_ptr(ptr: *const QuotationData) -> Self
pub fn from_quotation_ptr(ptr: *const QuotationData) -> Self
Create a NaN-boxed quotation pointer
Sourcepub fn from_closure_ptr(ptr: *const ClosureData) -> Self
pub fn from_closure_ptr(ptr: *const ClosureData) -> Self
Create a NaN-boxed closure pointer
Sourcepub fn from_channel_ptr(ptr: *const Arc<ChannelData>) -> Self
pub fn from_channel_ptr(ptr: *const Arc<ChannelData>) -> Self
Create a NaN-boxed channel pointer
Sourcepub fn from_weave_ctx_ptr(ptr: *const WeaveCtxData) -> Self
pub fn from_weave_ctx_ptr(ptr: *const WeaveCtxData) -> Self
Create a NaN-boxed weave context pointer
Sourcepub unsafe fn as_string_ptr(self) -> *const SeqString
pub unsafe fn as_string_ptr(self) -> *const SeqString
Sourcepub unsafe fn as_symbol_ptr(self) -> *const SeqString
pub unsafe fn as_symbol_ptr(self) -> *const SeqString
Sourcepub unsafe fn as_variant_ptr(self) -> *const Arc<VariantData>
pub unsafe fn as_variant_ptr(self) -> *const Arc<VariantData>
Sourcepub unsafe fn as_quotation_ptr(self) -> *const QuotationData
pub unsafe fn as_quotation_ptr(self) -> *const QuotationData
Sourcepub unsafe fn as_closure_ptr(self) -> *const ClosureData
pub unsafe fn as_closure_ptr(self) -> *const ClosureData
Sourcepub unsafe fn as_channel_ptr(self) -> *const Arc<ChannelData>
pub unsafe fn as_channel_ptr(self) -> *const Arc<ChannelData>
Sourcepub unsafe fn as_weave_ctx_ptr(self) -> *const WeaveCtxData
pub unsafe fn as_weave_ctx_ptr(self) -> *const WeaveCtxData
Source§impl NanBoxedValue
impl NanBoxedValue
Sourcepub fn from_value(value: &Value) -> Self
pub fn from_value(value: &Value) -> Self
Convert a Value to a NanBoxedValue
This clones heap-allocated data and stores pointers in the NaN-boxed format.
The caller is responsible for ensuring the returned NanBoxedValue is properly
dropped (via drop_nanboxed) to avoid memory leaks.
§Panics
Panics if an integer value is outside the 47-bit range.
Sourcepub unsafe fn to_value(self) -> Value
pub unsafe fn to_value(self) -> Value
Convert a NanBoxedValue back to a Value
This reconstructs the Value from the NaN-boxed representation. For heap-allocated types, this takes ownership of the underlying memory.
§Safety
The NanBoxedValue must have been created by from_value and not yet
converted back or dropped. Each NanBoxedValue should only be converted
to Value once.
Sourcepub fn clone_nanboxed(&self) -> Self
pub fn clone_nanboxed(&self) -> Self
Clone a NanBoxedValue, properly cloning any heap-allocated data
For pointer types, this creates new heap allocations.
Sourcepub unsafe fn drop_nanboxed(self)
pub unsafe fn drop_nanboxed(self)
Drop a NanBoxedValue, freeing any heap-allocated data
This must be called for NanBoxedValues that hold pointer types to avoid memory leaks.
§Safety
The NanBoxedValue must have been created by from_value or clone_nanboxed
and not yet dropped or converted to Value.
Trait Implementations§
Source§impl Clone for NanBoxedValue
impl Clone for NanBoxedValue
Source§fn clone(&self) -> NanBoxedValue
fn clone(&self) -> NanBoxedValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more