pub enum Closure {
One(Arc<str>, Conditional),
Two(Arc<str>, Arc<str>, Conditional),
Primary(Box<Primary>),
}Expand description
Closure (anonymous function) expression.
Variants:
One(name, body)– single-parameter closure.Two(name1, name2, body)– two-parameter closure.Primary(primary)– primary/conditional expression treated as a closure body.
Variants§
One(Arc<str>, Conditional)
Two(Arc<str>, Arc<str>, Conditional)
Primary(Box<Primary>)
Primary flattened AST optimization.
Implementations§
Source§impl Closure
impl Closure
Sourcepub fn invoke(&self, context: &mut dyn ContextLike) -> Result<Arc<Value>>
pub fn invoke(&self, context: &mut dyn ContextLike) -> Result<Arc<Value>>
Evaluate the closure body using parameter bindings already set in context.
Sourcepub fn call(
&self,
context: &mut dyn ContextLike,
arg: Arc<Value>,
) -> Result<Arc<Value>>
pub fn call( &self, context: &mut dyn ContextLike, arg: Arc<Value>, ) -> Result<Arc<Value>>
Call the closure with argument value(s) using the AIMX calling convention.
- Propagates
Value::Erratawithout evaluation. - Binds a single value to parameter index
0. - For arrays, binds element
0to parameter0and element1(if present) to parameter1. - Evaluates inside a closure scope (
start_closure/end_closure).
Trait Implementations§
Source§impl ExpressionLike for Closure
impl ExpressionLike for Closure
Source§fn evaluate(&self, context: &mut dyn ContextLike) -> Result<Arc<Value>>
fn evaluate(&self, context: &mut dyn ContextLike) -> Result<Arc<Value>>
Evaluate to a runtime value.
Primaryevaluates directly.- Other variants return
Value::Closurefor later invocation.
Source§fn to_formula(&self) -> String
fn to_formula(&self) -> String
Return the formula-string representation (round-trippable by the parser).
Source§impl WriterLike for Closure
impl WriterLike for Closure
Source§fn to_stringized(&self) -> String
fn to_stringized(&self) -> String
Return a string representation (raw unsafe output).
Source§fn to_sanitized(&self) -> String
fn to_sanitized(&self) -> String
Return a sanitized string representation (escaped for safe output).
Source§fn to_expressionized(&self) -> String
fn to_expressionized(&self) -> String
Return a sanitized string representation (escaped for safe output).
impl StructuralPartialEq for Closure
Auto Trait Implementations§
impl Freeze for Closure
impl RefUnwindSafe for Closure
impl Send for Closure
impl Sync for Closure
impl Unpin for Closure
impl UnwindSafe for Closure
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.