pub struct Node { /* private fields */ }Expand description
A node in the operator tree.
The operator tree is created by the crate-level build_operator_tree method.
It can be evaluated for a given context with the Node::eval method.
The advantage of constructing the operator tree separately from the actual evaluation is that it can be evaluated arbitrarily often with different contexts.
Implementations§
source§impl Node
impl Node
pub fn iter_identifiers(&self) -> impl Iterator<Item = &str>
sourcepub fn iter_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String>
pub fn iter_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String>
Returns an iterator over all identifiers in this expression, allowing mutation. Each occurrence of an identifier is returned separately.
sourcepub fn iter_variable_identifiers(&self) -> impl Iterator<Item = &str>
pub fn iter_variable_identifiers(&self) -> impl Iterator<Item = &str>
Returns an iterator over all variable identifiers in this expression. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_variable_identifiers_mut(
&mut self
) -> impl Iterator<Item = &mut String>
pub fn iter_variable_identifiers_mut( &mut self ) -> impl Iterator<Item = &mut String>
Returns an iterator over all variable identifiers in this expression, allowing mutation. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_read_variable_identifiers(&self) -> impl Iterator<Item = &str>
pub fn iter_read_variable_identifiers(&self) -> impl Iterator<Item = &str>
Returns an iterator over all read variable identifiers in this expression. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_read_variable_identifiers_mut(
&mut self
) -> impl Iterator<Item = &mut String>
pub fn iter_read_variable_identifiers_mut( &mut self ) -> impl Iterator<Item = &mut String>
Returns an iterator over all read variable identifiers in this expression, allowing mutation. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_write_variable_identifiers(&self) -> impl Iterator<Item = &str>
pub fn iter_write_variable_identifiers(&self) -> impl Iterator<Item = &str>
Returns an iterator over all write variable identifiers in this expression. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_write_variable_identifiers_mut(
&mut self
) -> impl Iterator<Item = &mut String>
pub fn iter_write_variable_identifiers_mut( &mut self ) -> impl Iterator<Item = &mut String>
Returns an iterator over all write variable identifiers in this expression, allowing mutation. Each occurrence of a variable identifier is returned separately.
sourcepub fn iter_function_identifiers(&self) -> impl Iterator<Item = &str>
pub fn iter_function_identifiers(&self) -> impl Iterator<Item = &str>
Returns an iterator over all function identifiers in this expression. Each occurrence of a function identifier is returned separately.
sourcepub fn iter_function_identifiers_mut(
&mut self
) -> impl Iterator<Item = &mut String>
pub fn iter_function_identifiers_mut( &mut self ) -> impl Iterator<Item = &mut String>
Returns an iterator over all function identifiers in this expression, allowing mutation. Each occurrence of a variable identifier is returned separately.
sourcepub fn eval_with_context(&self, context: &VariableMap) -> Result<Value>
pub fn eval_with_context(&self, context: &VariableMap) -> Result<Value>
Evaluates the operator tree rooted at this node with the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_with_context_mut(&self, context: &mut VariableMap) -> Result<Value>
pub fn eval_with_context_mut(&self, context: &mut VariableMap) -> Result<Value>
Evaluates the operator tree rooted at this node with the given mutable context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval(&self) -> Result<Value>
pub fn eval(&self) -> Result<Value>
Evaluates the operator tree rooted at this node. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_string_with_context(&self, context: &VariableMap) -> Result<String>
pub fn eval_string_with_context(&self, context: &VariableMap) -> Result<String>
Evaluates the operator tree rooted at this node into a string with an the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_float_with_context(&self, context: &VariableMap) -> Result<f64>
pub fn eval_float_with_context(&self, context: &VariableMap) -> Result<f64>
Evaluates the operator tree rooted at this node into a float with an the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_int_with_context(&self, context: &VariableMap) -> Result<i64>
pub fn eval_int_with_context(&self, context: &VariableMap) -> Result<i64>
Evaluates the operator tree rooted at this node into an integer with an the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_number_with_context(&self, context: &VariableMap) -> Result<f64>
pub fn eval_number_with_context(&self, context: &VariableMap) -> Result<f64>
Evaluates the operator tree rooted at this node into a float with an the given context. If the result of the expression is an integer, it is silently converted into a float. Fails /// if one of the operators in the expression tree fails.
sourcepub fn eval_boolean_with_context(&self, context: &VariableMap) -> Result<bool>
pub fn eval_boolean_with_context(&self, context: &VariableMap) -> Result<bool>
Evaluates the operator tree rooted at this node into a boolean with an the given context
Fails if one of the operators in the expression tree fails.
sourcepub fn eval_tuple_with_context(
&self,
context: &VariableMap
) -> Result<Vec<Value>>
pub fn eval_tuple_with_context( &self, context: &VariableMap ) -> Result<Vec<Value>>
Evaluates the operator tree rooted at this node into a tuple with an the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_empty_with_context(&self, context: &VariableMap) -> Result<()>
pub fn eval_empty_with_context(&self, context: &VariableMap) -> Result<()>
Evaluates the operator tree rooted at this node into an empty value with an the given context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_string_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<String>
pub fn eval_string_with_context_mut( &self, context: &mut VariableMap ) -> Result<String>
Evaluates the operator tree rooted at this node into a string with an the given mutable context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_float_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<f64>
pub fn eval_float_with_context_mut( &self, context: &mut VariableMap ) -> Result<f64>
Evaluates the operator tree rooted at this node into a float with an the given mutable context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_int_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<i64>
pub fn eval_int_with_context_mut( &self, context: &mut VariableMap ) -> Result<i64>
Evaluates the operator tree rooted at this node into an integer with an the given mutable context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_number_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<f64>
pub fn eval_number_with_context_mut( &self, context: &mut VariableMap ) -> Result<f64>
Evaluates the operator tree rooted at this node into a float with an the given mutable context. If the result of the expression is an integer, it is silently converted into a float. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_boolean_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<bool>
pub fn eval_boolean_with_context_mut( &self, context: &mut VariableMap ) -> Result<bool>
Evaluates the operator tree rooted at this node into a boolean with an the given mutable /// context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_tuple_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<Vec<Value>>
pub fn eval_tuple_with_context_mut( &self, context: &mut VariableMap ) -> Result<Vec<Value>>
Evaluates the operator tree rooted at this node into a tuple with an the given mutable /// context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_empty_with_context_mut(
&self,
context: &mut VariableMap
) -> Result<()>
pub fn eval_empty_with_context_mut( &self, context: &mut VariableMap ) -> Result<()>
Evaluates the operator tree rooted at this node into an empty value with an the given /// mutable context. Fails if one of the operators in the expression tree fails.
sourcepub fn eval_string(&self) -> Result<String>
pub fn eval_string(&self) -> Result<String>
Evaluates the operator tree rooted at this node into a string. Fails if one of the /// operators in the expression tree fails.
sourcepub fn eval_float(&self) -> Result<f64>
pub fn eval_float(&self) -> Result<f64>
Evaluates the operator tree rooted at this node into a float. Fails if one of the operators /// in the expression tree fails.
sourcepub fn eval_int(&self) -> Result<i64>
pub fn eval_int(&self) -> Result<i64>
Evaluates the operator tree rooted at this node into an integer. Fails if one of the
operators in the expression tree fails.
sourcepub fn eval_number(&self) -> Result<f64>
pub fn eval_number(&self) -> Result<f64>
Evaluates the operator tree rooted at this node into a float. If the result of the
expression is an integer, it is silently converted into a float. Fails if one of the /// operators in the expression tree fails.
sourcepub fn eval_boolean(&self) -> Result<bool>
pub fn eval_boolean(&self) -> Result<bool>
Evaluates the operator tree rooted at this node into a boolean. Fails if one of the /// operators in the expression tree fails.
sourcepub fn eval_tuple(&self) -> Result<Vec<Value>>
pub fn eval_tuple(&self) -> Result<Vec<Value>>
Evaluates the operator tree rooted at this node into a tuple. Fails if one of the operators /// in the expression tree fails.
sourcepub fn eval_empty(&self) -> Result<()>
pub fn eval_empty(&self) -> Result<()>
Evaluates the operator tree rooted at this node into an empty value. Fails if one of the /// operators in the expression tree fails.
sourcepub fn children_mut(&mut self) -> &mut Vec<Node>
pub fn children_mut(&mut self) -> &mut Vec<Node>
Returns a mutable reference to the vector containing the children of this node.
WARNING: Writing to this might have unexpected results, as some operators require certain amounts and types of arguments.
sourcepub fn operator_mut(&mut self) -> &mut Operator
pub fn operator_mut(&mut self) -> &mut Operator
Returns a mutable reference to the operator associated with this node.
WARNING: Writing to this might have unexpected results, as some operators require different amounts and types of arguments.