pub enum Value<'gc> {
Show 16 variants
Number(f64),
Boolean(bool),
String(InternedString<'gc>),
IoString(Gc<'gc, String>),
Closure(Gc<'gc, Closure<'gc>>),
NativeFunction(NativeFn<'gc>),
List(GcRefLock<'gc, List<'gc>>),
Object(GcRefLock<'gc, Object<'gc>>),
Enum(GcRefLock<'gc, Enum<'gc>>),
EnumVariant(Gc<'gc, EnumVariant<'gc>>),
Class(GcRefLock<'gc, Class<'gc>>),
Instance(GcRefLock<'gc, Instance<'gc>>),
BoundMethod(Gc<'gc, BoundMethod<'gc>>),
Module(InternedString<'gc>),
Agent(Gc<'gc, Agent<'gc>>),
Nil,
}
Variants§
Number(f64)
Boolean(bool)
String(InternedString<'gc>)
IoString(Gc<'gc, String>)
Closure(Gc<'gc, Closure<'gc>>)
NativeFunction(NativeFn<'gc>)
List(GcRefLock<'gc, List<'gc>>)
Object(GcRefLock<'gc, Object<'gc>>)
Enum(GcRefLock<'gc, Enum<'gc>>)
EnumVariant(Gc<'gc, EnumVariant<'gc>>)
Class(GcRefLock<'gc, Class<'gc>>)
Instance(GcRefLock<'gc, Instance<'gc>>)
BoundMethod(Gc<'gc, BoundMethod<'gc>>)
Module(InternedString<'gc>)
Agent(Gc<'gc, Agent<'gc>>)
Nil
Implementations§
Source§impl<'gc> Value<'gc>
impl<'gc> Value<'gc>
pub fn array(mc: &Mutation<'gc>, data: Vec<Value<'gc>>) -> Self
pub fn equals(&self, other: &Value<'gc>) -> bool
pub fn as_number(self) -> Result<f64, VmError>
pub fn as_boolean(&self) -> bool
pub fn as_string(self) -> Result<InternedString<'gc>, VmError>
pub fn as_string_value(&self) -> Result<StringValue<'gc>, VmError>
pub fn new_string(ctx: Context<'gc>, s: &str, should_intern: bool) -> Value<'gc>
pub fn as_closure(self) -> Result<Gc<'gc, Closure<'gc>>, VmError>
pub fn as_array(self) -> Result<GcRefLock<'gc, List<'gc>>, VmError>
pub fn as_agent(self) -> Result<Gc<'gc, Agent<'gc>>, VmError>
pub fn as_class(self) -> Result<GcRefLock<'gc, Class<'gc>>, VmError>
pub fn is_error(&self) -> bool
pub fn is_object(&self) -> bool
pub fn is_bound_method(&self) -> bool
pub fn is_class(&self) -> bool
pub fn is_instance(&self) -> bool
pub fn is_closure(&self) -> bool
pub fn is_native_function(&self) -> bool
pub fn is_nil(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_true(&self) -> bool
pub fn is_falsy(&self) -> bool
pub fn from_serde_value(ctx: Context<'gc>, value: &Value) -> Value<'gc>
pub fn to_serde_value(&self) -> Value
Trait Implementations§
Source§impl<'gc> Collect for Value<'gc>
impl<'gc> Collect for Value<'gc>
Source§fn needs_trace() -> bool
fn needs_trace() -> bool
As an optimization, if this type can never hold a
Gc
pointer and trace
is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace
must be called.Source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Must call
Collect::trace
on all held Gc
pointers. If this type holds inner types that
implement Collect
, a valid implementation would simply call Collect::trace
on all the
held values to ensure this.Source§impl<'gc> From<Value<'gc>> for ReturnValue
impl<'gc> From<Value<'gc>> for ReturnValue
impl<'gc> Copy for Value<'gc>
Auto Trait Implementations§
impl<'gc> Freeze for Value<'gc>
impl<'gc> !RefUnwindSafe for Value<'gc>
impl<'gc> !Send for Value<'gc>
impl<'gc> !Sync for Value<'gc>
impl<'gc> Unpin for Value<'gc>
impl<'gc> !UnwindSafe for Value<'gc>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.