Enum egglang::expression::Value
source · pub enum Value {
Nil,
Number(OrderedFloat<f32>),
Boolean(bool),
String(ArcStr),
Function(usize),
Object(usize),
}
Expand description
A primitive in Egg; can be a number, boolean, string, function, or an object.
Most primitives are immutable, to mutate create a new value.
Objects
are mutable, and can be modified in-place.
Functions
are technically also mutable as they are stored by reference, but there’s no actual built-in path to mutation.
Some Rust primitives can be converted into a Value
using the From
trait.
use egglang::expression::Value;
let number: Value = 42.0.into();
let string: Value = "Hello, World!".into();
let boolean: Value = true.into();
let nil: Value = ().into();
// Option<T: Into<Value>> can be converted into Value
assert_eq!(Value::Nil, None::<f32>.into());
let five: Value = Some(5.0).into();
assert_eq!(Value::from(5.0), five);
Variants§
Nil
Represents the absence of a value.
Number(OrderedFloat<f32>)
A 32-bit floating-point number.
Boolean(bool)
A boolean value.
String(ArcStr)
Atomically reference-counted string.
Function(usize)
A function definition. Stores a index to the function in the scope.
Object(usize)
An object. Stores a index to the object in the scope.
Trait Implementations§
source§impl Ord for Value
impl Ord for Value
source§impl PartialEq for Value
impl PartialEq for Value
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Value
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more