pub enum Value {
Show 15 variants
Int(i64),
Float(f64),
Bool(bool),
Char(char),
String(String),
Array(Vec<Value>),
Tuple(Vec<Value>),
Struct {
name: String,
fields: HashMap<String, Value>,
},
Function {
name: String,
params: Vec<(String, Type)>,
body: Box<Expr>,
closure_env: Option<Environment>,
},
Closure {
params: Vec<(String, Option<Type>)>,
body: Box<Expr>,
env: Environment,
},
Option(Option<Box<Value>>),
Unit,
Break(Option<Box<Value>>),
Continue,
Return(Option<Box<Value>>),
}Expand description
A runtime value produced by evaluating an expression.
Every result of evaluation is represented as a Value. This includes
primitive types (int, float, bool, char, string), compound types
(array, tuple, struct), callable types (function, closure), and
control-flow sentinels (break, continue, return).
Variants§
Int(i64)
Float(f64)
Bool(bool)
Char(char)
String(String)
Array(Vec<Value>)
Tuple(Vec<Value>)
Struct
Function
Closure
Option(Option<Box<Value>>)
Unit
Break(Option<Box<Value>>)
Signals a break with an optional value.
Continue
Signals a continue.
Return(Option<Box<Value>>)
Signals a return with an optional value.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin 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