#[repr(transparent)]pub struct RawValue(_, _);
Expand description
An unsafe value used internally in the VM.
Does not provide any safety guarantees as to GC’d object lifetimes.
You almost always want Value
instead of this.
Implementations
sourceimpl RawValue
impl RawValue
sourcepub unsafe fn get_boolean_unchecked(&self) -> bool
pub unsafe fn get_boolean_unchecked(&self) -> bool
Returns a boolean value without performing any checks.
Safety
Calling this on a value that isn’t known to be a boolean is undefined behavior.
sourcepub unsafe fn get_number_unchecked(&self) -> &f64
pub unsafe fn get_number_unchecked(&self) -> &f64
Returns a number value without performing any checks.
Safety
Calling this on a value that isn’t known to be a number is undefined behavior.
sourcepub unsafe fn get_raw_string_unchecked(&self) -> GcRaw<String>
pub unsafe fn get_raw_string_unchecked(&self) -> GcRaw<String>
Returns a string value without performing any checks.
Safety
Calling this on a value that isn’t known to be a string is undefined behavior.
sourcepub unsafe fn get_raw_function_unchecked(&self) -> GcRaw<Closure>
pub unsafe fn get_raw_function_unchecked(&self) -> GcRaw<Closure>
Returns a function value without performing any checks.
Safety
Calling this on a value that isn’t known to be a function is undefined behavior.
sourcepub unsafe fn get_raw_struct_unchecked(&self) -> GcRaw<Struct>
pub unsafe fn get_raw_struct_unchecked(&self) -> GcRaw<Struct>
Returns a struct value without performing any checks.
Safety
Calling this on a value that isn’t known to be a struct is undefined behavior.
sourcepub unsafe fn get_raw_trait_unchecked(&self) -> GcRaw<Trait>
pub unsafe fn get_raw_trait_unchecked(&self) -> GcRaw<Trait>
Returns a trait value without performing any checks.
Safety
Calling this on a value that isn’t known to be a trait is undefined behavior.
sourcepub unsafe fn get_raw_list_unchecked(&self) -> GcRaw<List>
pub unsafe fn get_raw_list_unchecked(&self) -> GcRaw<List>
Returns a list value without performing any checks.
Safety
Calling this on a value that isn’t known to be a list is undefined behavior.
sourcepub unsafe fn get_raw_dict_unchecked(&self) -> GcRaw<Dict>
pub unsafe fn get_raw_dict_unchecked(&self) -> GcRaw<Dict>
Returns a dict value without performing any checks.
Safety
Calling this on a value that isn’t known to be a dict is undefined behavior.
sourcepub unsafe fn get_raw_user_data_unchecked(&self) -> GcRaw<Box<dyn UserData>>
pub unsafe fn get_raw_user_data_unchecked(&self) -> GcRaw<Box<dyn UserData>>
Returns a user data value without performing any checks.
Safety
Calling this on a value that isn’t known to be a user data is undefined behavior.
sourcepub fn ensure_nil(&self) -> Result<(), LanguageErrorKind>
pub fn ensure_nil(&self) -> Result<(), LanguageErrorKind>
Ensures the value is a Nil
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_boolean(&self) -> Result<bool, LanguageErrorKind>
pub fn ensure_boolean(&self) -> Result<bool, LanguageErrorKind>
Ensures the value is a Boolean
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_number(&self) -> Result<f64, LanguageErrorKind>
pub fn ensure_number(&self) -> Result<f64, LanguageErrorKind>
Ensures the value is a Number
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_raw_string(&self) -> Result<GcRaw<String>, LanguageErrorKind>
pub fn ensure_raw_string(&self) -> Result<GcRaw<String>, LanguageErrorKind>
Ensures the value is a String
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_raw_function(&self) -> Result<GcRaw<Closure>, LanguageErrorKind>
pub fn ensure_raw_function(&self) -> Result<GcRaw<Closure>, LanguageErrorKind>
Ensures the value is a Function
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_raw_struct(&self) -> Result<GcRaw<Struct>, LanguageErrorKind>
pub fn ensure_raw_struct(&self) -> Result<GcRaw<Struct>, LanguageErrorKind>
Ensures the value is a Struct
, returning a type mismatch error if that’s not the case.
sourcepub fn ensure_raw_trait(&self) -> Result<GcRaw<Trait>, LanguageErrorKind>
pub fn ensure_raw_trait(&self) -> Result<GcRaw<Trait>, LanguageErrorKind>
Ensures the value is a Trait
, returning a type mismatch error if that’s not the case.
sourcepub fn get_raw_user_data<T>(&self) -> Option<GcRaw<Box<dyn UserData>>>where
T: UserData,
pub fn get_raw_user_data<T>(&self) -> Option<GcRaw<Box<dyn UserData>>>where
T: UserData,
Ensures the value is a UserData
of the given type T
, returning a type mismatch error
that’s not the case.
sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Returns whether the value is truthy. All values except Nil
and False
are truthy.
sourcepub fn is_falsy(&self) -> bool
pub fn is_falsy(&self) -> bool
Returns whether the values is falsy. The only falsy values are Nil
and False
.
sourcepub fn try_partial_cmp(
&self,
other: &Self
) -> Result<Option<Ordering>, LanguageErrorKind>
pub fn try_partial_cmp(
&self,
other: &Self
) -> Result<Option<Ordering>, LanguageErrorKind>
Attempts to partially compare this value with another one.
Returns an error if the types of the two values are not the same.