pub struct ExprOptions {
pub op: IndexMap<String, Option<OpDef>>,
pub evaluate: Option<Evaluate>,
pub juxtapose: Option<bool>,
}Expand description
Options for the plugin.
op is an insertion-ordered map, and the order matters: two operators
claiming the same source string resolve to the same token, and the
later entry wins, exactly as it does in the canonical TypeScript. A
None entry deletes an operator the defaults provide.
Fields§
§op: IndexMap<String, Option<OpDef>>§evaluate: Option<Evaluate>§juxtapose: Option<bool>Values side by side, with nothing between them, inside an
expression or a paren group make an implicit list, as jsonic makes
one (f(a b) is a call of [a, b]). With Some(false) they are
refused, with the engine’s unexpected. A document’s own implicit
list, outside any expression, and the items of a list or a map are
unchanged. None reads as true.
Implementations§
Source§impl ExprOptions
impl ExprOptions
Sourcepub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
pub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
Add or replace one operator definition.
Sourcepub fn without_op(self, name: impl Into<String>) -> Self
pub fn without_op(self, name: impl Into<String>) -> Self
Delete a default operator, the Rust spelling of plain: null.
Sourcepub fn with_juxtapose(self, juxtapose: bool) -> Self
pub fn with_juxtapose(self, juxtapose: bool) -> Self
Whether values side by side make an implicit list: see
ExprOptions::juxtapose.
Sourcepub fn with_evaluate(
self,
evaluate: impl Fn(&mut EvalSite<'_>, &Op, &[Value]) -> Value + Send + Sync + 'static,
) -> Self
pub fn with_evaluate( self, evaluate: impl Fn(&mut EvalSite<'_>, &Op, &[Value]) -> Value + Send + Sync + 'static, ) -> Self
Set the evaluator that reduces each expression as it closes.
Sourcepub fn from_value(options: &Value) -> Self
pub fn from_value(options: &Value) -> Self
Read the operator table, and juxtapose, out of a serialized option
bag, as the engine hands it to a plugin. Unreadable entries are
ignored, the way the canonical plugin ignores what it cannot use.