pub enum Value {
Show 24 variants
Int(Num),
Float(f64),
Str(SharedText),
Bool(bool),
Null,
Absent,
Undef,
Q(Box<QuantityValue>),
Ref(Rc<SegPath>),
Rec(Rc<RefCell<RecInst>>),
Arr(Rc<RefCell<ArrV>>),
Map(Rc<RefCell<MapV>>),
Range(Box<RangeValue>),
Clo(Rc<Closure>),
Nat(NatFn),
Std(Rc<Vec<String>>),
NsRef(Rc<NsRefV>),
Pat(SharedText),
PreObj(Rc<Vec<(String, Value)>>),
PreArr(Rc<Vec<(bool, Value)>>),
PreVal(Rc<PreValV>),
JObj(Rc<Vec<(String, Value)>>),
JArr(Rc<Vec<Value>>),
Segs(Rc<SegPath>),
}Expand description
a runtime value (§9): the scalars, quantities, references, and instances, and the engine’s intermediate forms
Variants§
Int(Num)
an integer
Float(f64)
a float
Str(SharedText)
a string
Bool(bool)
a boolean
Null
null
Absent
an absent optional member (§4.6)
Undef
not yet computed
Q(Box<QuantityValue>)
a quantity
Ref(Rc<SegPath>)
a reference, by canonical path
Rec(Rc<RefCell<RecInst>>)
a record instance
Arr(Rc<RefCell<ArrV>>)
an array
Map(Rc<RefCell<MapV>>)
a map
Range(Box<RangeValue>)
a range value
Clo(Rc<Closure>)
a closure
Nat(NatFn)
a native function
Std(Rc<Vec<String>>)
a standard-library path, partially spelled
NsRef(Rc<NsRefV>)
a namespace
Pat(SharedText)
a pattern
PreObj(Rc<Vec<(String, Value)>>)
a record literal not yet bound
PreArr(Rc<Vec<(bool, Value)>>)
an array literal not yet bound: (spread, item)
PreVal(Rc<PreValV>)
an expression not yet evaluated, with its scope
JObj(Rc<Vec<(String, Value)>>)
a JSON object, as read
JArr(Rc<Vec<Value>>)
a JSON array, as read
Segs(Rc<SegPath>)
a path value
Implementations§
Source§impl Value
impl Value
Sourcepub fn quantity(dim: impl Into<String>, value: f64) -> Self
pub fn quantity(dim: impl Into<String>, value: f64) -> Self
Construct a quantity with a base-unit magnitude and a dimension key. Display units remain properties of the environment, not this value.
Sourcepub fn as_quantity(&self) -> Option<(&str, f64)>
pub fn as_quantity(&self) -> Option<(&str, f64)>
Borrow the dimension and read the independently stored magnitude.
Sourcepub fn quantity_dimension_mut(&mut self) -> Option<&mut String>
pub fn quantity_dimension_mut(&mut self) -> Option<&mut String>
Mutate a dimension without changing a retained clone’s dimension.
Sourcepub fn as_quantity_mut(&mut self) -> Option<&mut QuantityValue>
pub fn as_quantity_mut(&mut self) -> Option<&mut QuantityValue>
Mutate this quantity’s independently owned magnitude or dimension owner.
Sourcepub fn range(lo: Value, hi: Value, excl: bool) -> Self
pub fn range(lo: Value, hi: Value, excl: bool) -> Self
Construct a range without evaluating or restricting its endpoints. Iteration and membership retain their existing validation boundaries.
Sourcepub fn as_range(&self) -> Option<&RangeValue>
pub fn as_range(&self) -> Option<&RangeValue>
Borrow a range’s uniquely owned endpoints and exclusion flag.
Sourcepub fn as_range_mut(&mut self) -> Option<&mut RangeValue>
pub fn as_range_mut(&mut self) -> Option<&mut RangeValue>
Mutate this range’s endpoints; ordinary Value clone rules still apply to containers or native captures stored inside those endpoints.
Sourcepub fn pattern(src: impl Into<Rc<str>>) -> Self
pub fn pattern(src: impl Into<Rc<str>>) -> Self
Construct pattern text. Pattern equality remains non-reflexive.
Sourcepub fn as_pattern(&self) -> Option<&str>
pub fn as_pattern(&self) -> Option<&str>
Borrow pattern text without exposing its shared storage.