pub enum Value {
Primitive(Primitive),
Symbol(SymbolRef),
Dynamic(AnyDynamic),
}Expand description
A Muse virtual machine value.
Variants§
Primitive(Primitive)
Symbol(SymbolRef)
A symbol.
Dynamic(AnyDynamic)
A dynamically allocated, garbage collected type.
Implementations§
source§impl Value
impl Value
pub const TRUE: Self = _
pub const FALSE: Self = _
pub const NIL: Self = _
pub const ZERO: Self = _
sourcepub fn upgrade(&self, guard: &CollectionGuard<'_>) -> Option<RootedValue>
pub fn upgrade(&self, guard: &CollectionGuard<'_>) -> Option<RootedValue>
Returns this value with any garbage collected values upgraded to root references.
sourcepub fn dynamic<'guard, T>(
value: T,
guard: &impl AsRef<CollectionGuard<'guard>>,
) -> Selfwhere
T: DynamicValue + Trace,
pub fn dynamic<'guard, T>(
value: T,
guard: &impl AsRef<CollectionGuard<'guard>>,
) -> Selfwhere
T: DynamicValue + Trace,
Moves value into the virtual machine.
sourcepub fn as_primitive(&self) -> Option<Primitive>
pub fn as_primitive(&self) -> Option<Primitive>
Returns this value as an i64, if possible.
sourcepub fn as_symbol_ref(&self) -> Option<&SymbolRef>
pub fn as_symbol_ref(&self) -> Option<&SymbolRef>
Returns this value as a SymbolRef, if possible.
sourcepub fn as_symbol(&self, guard: &CollectionGuard<'_>) -> Option<Symbol>
pub fn as_symbol(&self, guard: &CollectionGuard<'_>) -> Option<Symbol>
Returns this value as a Symbol, if possible.
sourcepub fn as_any_dynamic(&self) -> Option<AnyDynamic>
pub fn as_any_dynamic(&self) -> Option<AnyDynamic>
Returns this value as an AnyDynamic, if possible.
sourcepub fn as_dynamic<T>(&self) -> Option<Dynamic<T>>where
T: DynamicValue + Trace,
pub fn as_dynamic<T>(&self) -> Option<Dynamic<T>>where
T: DynamicValue + Trace,
Returns this value as a Dynamic<T>, if this value contains a T.
sourcepub fn as_rooted<T>(&self, guard: &CollectionGuard<'_>) -> Option<Rooted<T>>where
T: DynamicValue + Trace,
pub fn as_rooted<T>(&self, guard: &CollectionGuard<'_>) -> Option<Rooted<T>>where
T: DynamicValue + Trace,
Returns this value as a Rooted<T>, if this value contains a T.
sourcepub fn as_downcast_ref<'guard, T>(
&self,
guard: &'guard CollectionGuard<'_>,
) -> Option<&'guard T>where
T: DynamicValue + Trace,
pub fn as_downcast_ref<'guard, T>(
&self,
guard: &'guard CollectionGuard<'_>,
) -> Option<&'guard T>where
T: DynamicValue + Trace,
Returns this value as a&T, if this value contains a T.
sourcepub fn truthy(&self, vm: &mut VmContext<'_, '_>) -> bool
pub fn truthy(&self, vm: &mut VmContext<'_, '_>) -> bool
Returns true if this value should be considered true in a boolean
expression.
sourcepub fn call(
&self,
vm: &mut VmContext<'_, '_>,
arity: impl Into<Arity>,
) -> Result<Value, Fault>
pub fn call( &self, vm: &mut VmContext<'_, '_>, arity: impl Into<Arity>, ) -> Result<Value, Fault>
Invokes this value as a function.
sourcepub fn invoke(
&self,
vm: &mut VmContext<'_, '_>,
name: &SymbolRef,
arity: impl Into<Arity>,
) -> Result<Value, Fault>
pub fn invoke( &self, vm: &mut VmContext<'_, '_>, name: &SymbolRef, arity: impl Into<Arity>, ) -> Result<Value, Fault>
Invokes name on this value.
sourcepub fn add(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn add( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Adds self to rhs.
sourcepub fn sub(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn sub( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Subtracts rhs from self.
sourcepub fn mul(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn mul( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Multiplies self by rhs.
sourcepub fn pow(
&self,
vm: &mut VmContext<'_, '_>,
exp: &Self,
) -> Result<Value, Fault>
pub fn pow( &self, vm: &mut VmContext<'_, '_>, exp: &Self, ) -> Result<Value, Fault>
Raises self to the rhs power.
sourcepub fn div(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn div( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Divides self by rhs.
sourcepub fn idiv(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn idiv( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Divides self by rhs, using whole numbers.
sourcepub fn rem(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Self,
) -> Result<Value, Fault>
pub fn rem( &self, vm: &mut VmContext<'_, '_>, rhs: &Self, ) -> Result<Value, Fault>
Calcualtes the remainder of dividing self by rhs using whole
numbers.
sourcepub fn not(&self, vm: &mut VmContext<'_, '_>) -> Result<Self, Fault>
pub fn not(&self, vm: &mut VmContext<'_, '_>) -> Result<Self, Fault>
Returns the inverse of Self::truthy.
sourcepub fn bitwise_not(&self, vm: &mut VmContext<'_, '_>) -> Result<Self, Fault>
pub fn bitwise_not(&self, vm: &mut VmContext<'_, '_>) -> Result<Self, Fault>
Returns the bitwise not of this value.
sourcepub fn bitwise_and(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Value,
) -> Result<Self, Fault>
pub fn bitwise_and( &self, vm: &mut VmContext<'_, '_>, rhs: &Value, ) -> Result<Self, Fault>
Returns the bitwise and of self and rhs.
sourcepub fn bitwise_or(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Value,
) -> Result<Self, Fault>
pub fn bitwise_or( &self, vm: &mut VmContext<'_, '_>, rhs: &Value, ) -> Result<Self, Fault>
Returns the bitwise or of self and rhs.
sourcepub fn bitwise_xor(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Value,
) -> Result<Self, Fault>
pub fn bitwise_xor( &self, vm: &mut VmContext<'_, '_>, rhs: &Value, ) -> Result<Self, Fault>
Returns the bitwise xor of self and rhs.
sourcepub fn shift_left(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Value,
) -> Result<Self, Fault>
pub fn shift_left( &self, vm: &mut VmContext<'_, '_>, rhs: &Value, ) -> Result<Self, Fault>
Returns the bitwise shift left of self by rhs.
sourcepub fn shift_right(
&self,
vm: &mut VmContext<'_, '_>,
rhs: &Value,
) -> Result<Self, Fault>
pub fn shift_right( &self, vm: &mut VmContext<'_, '_>, rhs: &Value, ) -> Result<Self, Fault>
Returns the shift right of self by rhs.
sourcepub fn to_string(&self, vm: &mut VmContext<'_, '_>) -> Result<SymbolRef, Fault>
pub fn to_string(&self, vm: &mut VmContext<'_, '_>) -> Result<SymbolRef, Fault>
Returns this value as a shared string reference.
sourcepub fn map_str<R>(
&self,
vm: &mut VmContext<'_, '_>,
map: impl FnOnce(&mut VmContext<'_, '_>, &str) -> R,
) -> Result<R, Fault>
pub fn map_str<R>( &self, vm: &mut VmContext<'_, '_>, map: impl FnOnce(&mut VmContext<'_, '_>, &str) -> R, ) -> Result<R, Fault>
Maps the contents of this value as a str, if possible.
sourcepub fn hash_into(&self, vm: &mut VmContext<'_, '_>, hasher: &mut ValueHasher)
pub fn hash_into(&self, vm: &mut VmContext<'_, '_>, hasher: &mut ValueHasher)
Hashes this value into hasher.
sourcepub fn equals(
&self,
vm: ContextOrGuard<'_, '_, '_>,
other: &Self,
) -> Result<bool, Fault>
pub fn equals( &self, vm: ContextOrGuard<'_, '_, '_>, other: &Self, ) -> Result<bool, Fault>
Returns true if self and other are equivalent values.
sourcepub fn matches(
&self,
vm: &mut VmContext<'_, '_>,
other: &Self,
) -> Result<bool, Fault>
pub fn matches( &self, vm: &mut VmContext<'_, '_>, other: &Self, ) -> Result<bool, Fault>
Returns true if self matches other.
sourcepub fn total_cmp(
&self,
vm: &mut VmContext<'_, '_>,
other: &Self,
) -> Result<Ordering, Fault>
pub fn total_cmp( &self, vm: &mut VmContext<'_, '_>, other: &Self, ) -> Result<Ordering, Fault>
Returns an ordering of self and other that takes into account both
the type of data and the value itself.
sourcepub fn deep_clone(&self, guard: &CollectionGuard<'_>) -> Option<Value>
pub fn deep_clone(&self, guard: &CollectionGuard<'_>) -> Option<Value>
Perform a deep-clone on the contents of this value.
Not all types are able to be deeply cloned. Unsupported types will
result in None.
Trait Implementations§
source§impl FromIterator<Value> for List
impl FromIterator<Value> for List
impl Copy for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<A> Cast for A
impl<A> Cast for A
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)