RawValue

Struct RawValue 

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

A dynamically-typed, raw value. Does not provide any safety guarantees.

Implementations§

Source§

impl RawValue

Source

pub fn hash<H>(&self, state: &mut H) -> u64
where H: Hasher,

Hashes the value. Note that this is not part of a std::hash::Hash implementation because this may get extra arguments in the future to support overloading hashing from the language itself.

Source§

impl RawValue

Source

pub fn kind(&self) -> ValueKind

Returns the kind of value stored.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn ensure_nil(&self) -> Result<(), ErrorKind>

Ensures the value is a Nil, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_boolean(&self) -> Result<bool, ErrorKind>

Ensures the value is a Boolean, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_number(&self) -> Result<f64, ErrorKind>

Ensures the value is a Number, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_raw_string(&self) -> Result<GcRaw<String>, ErrorKind>

Ensures the value is a String, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_raw_function(&self) -> Result<GcRaw<Closure>, ErrorKind>

Ensures the value is a Function, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_raw_struct(&self) -> Result<GcRaw<Struct>, ErrorKind>

Ensures the value is a Struct, returning a type mismatch error if that’s not the case.

Source

pub fn ensure_raw_trait(&self) -> Result<GcRaw<Trait>, ErrorKind>

Ensures the value is a Trait, returning a type mismatch error if that’s not the case.

Source

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.

Source

pub fn is_truthy(&self) -> bool

Returns whether the value is truthy. All values except Nil and False are truthy.

Source

pub fn is_falsy(&self) -> bool

Returns whether the values is falsy. The only falsy values are Nil and False.

Source

pub fn try_partial_cmp( &self, other: &Self, ) -> Result<Option<Ordering>, ErrorKind>

Attempts to partially compare this value with another one.

Returns an error if the types of the two values are not the same.

Trait Implementations§

Source§

impl Clone for RawValue

Source§

fn clone(&self) -> RawValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RawValue

Source§

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

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

impl Default for RawValue

Source§

fn default() -> Self

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

impl Display for RawValue

Source§

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

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

impl From<()> for RawValue

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<Box<dyn UserData>>> for RawValue

Source§

fn from(u: GcRaw<Box<dyn UserData>>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<Closure>> for RawValue

Source§

fn from(f: GcRaw<Closure>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<Dict>> for RawValue

Source§

fn from(s: GcRaw<Dict>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<List>> for RawValue

Source§

fn from(s: GcRaw<List>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<String>> for RawValue

Source§

fn from(s: GcRaw<String>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<Struct>> for RawValue

Source§

fn from(s: GcRaw<Struct>) -> Self

Converts to this type from the input type.
Source§

impl From<GcRaw<Trait>> for RawValue

Source§

fn from(t: GcRaw<Trait>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for RawValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for RawValue

Source§

fn from(x: f64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RawValue

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RawValue

Source§

impl StructuralPartialEq for RawValue

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.