pub enum Value {
Number(f64),
Fraction(Ratio<BigInt>),
String(String),
Boolean(bool),
Null,
Array(Vec<Value>),
Dict(HashMap<String, Value>),
Function {
name: Option<String>,
params: Vec<String>,
body: Vec<Located>,
env: Rc<RefCell<Environment>>,
file: Option<String>,
},
Generator {
inner: Rc<RefCell<GeneratorInner>>,
},
Lazy {
expr: Expr,
env: Rc<RefCell<Environment>>,
cached: Option<Box<Value>>,
},
BuiltIn {
name: String,
arity: usize,
},
}Expand description
Runtime value types
Variants§
Number(f64)
Numeric value (f64)
Fraction(Ratio<BigInt>)
Rational number (exact fraction)
String(String)
String value
Boolean(bool)
Boolean value
Null
Null value
Array(Vec<Value>)
Array of values
Dict(HashMap<String, Value>)
Dictionary (key-value map)
Function
Function (closure)
Fields
§
env: Rc<RefCell<Environment>>Generator
Generator(生成器实例)
语义(0.6.0 冻结,用户选择「首次触发急切收集」):
第一次 NEXT(G) 时完整执行函数体一次,所有 Yield 值
按序收入内核缓冲;此后 NEXT 逐个弹出,耗尽返回 Null。
函数体内的副作用因此恰好发生一次。无限生成器会在收集
阶段触发步数上限报错,而不是挂起。
Fields
§
inner: Rc<RefCell<GeneratorInner>>共享内核:克隆生成器值(如 Set G2 G)消费同一序列,
类似 Python 迭代器语义
Lazy
Lazy value (computed on demand)
BuiltIn
Built-in function
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl !UnwindSafe for Value
impl Forget for Value
impl Freeze for Value
impl Move for Value
impl Unpin for Value
impl UnsafeUnpin 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