pub enum Value {
}Expand description
A run-time value.
The data variants are data.md’s built-in types and types.md’s records,
enums, tuples and Unit. The last three are values a run holds but that
are not data: they have no equality, order, text or encoding, and every
operation that would need one refuses them with DataError::NotData.
An aggregate holding one is not data either, and the refusal is reached
when the operation reaches it.
Cloning is cheap: every aggregate shares its parts.
Variants§
Unit
(), the one value of Unit.
Bool(bool)
true or false.
Int(Int)
An integer.
Decimal(Decimal)
An exact decimal.
Text(Text)
A sequence of code points.
Bytes(Bytes)
A sequence of bytes.
List(List)
A list.
Dict(Dict)
A dictionary, sorted by key.
Set(Set)
A set, sorted.
Tuple(Tuple)
A tuple of at least two parts.
Record(Record)
A record value.
Variant(Variant)
An enum value: a constructor and its payload.
Duration(Duration)
A length of time.
Instant(Instant)
A point in time.
Native(Native)
A value the evaluator implements and this crate cannot see into: a function, a closure, a compiled pattern.
Task(TaskId)
A handle to a running task.
Host(HostToken)
A value of a @tool type: the token the host chose for it.
Implementations§
Source§impl Value
impl Value
Sourcepub fn list(items: impl IntoIterator<Item = Value>) -> Value
pub fn list(items: impl IntoIterator<Item = Value>) -> Value
Returns a list of items, in order.
Sourcepub fn tuple(parts: impl IntoIterator<Item = Value>) -> Value
pub fn tuple(parts: impl IntoIterator<Item = Value>) -> Value
Returns a tuple of parts, in order.
Source§impl Value
impl Value
Sourcepub fn depth_bound(&self) -> usize
pub fn depth_bound(&self) -> usize
How deeply the value nests, or more: a scalar is 0 deep and an
aggregate one deeper than its deepest part, so [[1]] is 2 deep.
It costs constant time, since every aggregate records it when it is
made. It is exact but for a list, a dictionary or a set that kept the
measure of a larger one it was cut from — a part of a list, or a
dictionary an entry was removed from — which may report more than it
holds; Value::deeper_than is exact.
Sourcepub fn may_hold_tasks(&self) -> bool
pub fn may_hold_tasks(&self) -> bool
Whether some part of the value may be a task handle or a Native
value, which may itself hold one; false means no part is either.
It costs constant time, and like Value::depth_bound may answer
true for a list, dictionary or set that kept the measure of a
larger one.
Sourcepub fn deeper_than(&self, bound: usize) -> bool
pub fn deeper_than(&self, bound: usize) -> bool
Whether the value nests more than bound levels deep.
The answer is exact. It costs constant time when the measure each aggregate records settles it, and otherwise walks only the parts whose measures do not: those of a part cut from a deeper list. The walk is iterative, so a value nested deeper than the native stack is measured too.