From 1646a070a90f115d2b7aa91dc9edb20f95b1ac49 Mon Sep 17 00:00:00 2001 From: Ben Weinstein-Raun Date: Fri, 2 Jun 2023 19:00:42 -0700 Subject: [PATCH] cargo format --- src/tree/iter.rs | 5 ++--- src/tree/mod.rs | 51 ++++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/tree/iter.rs b/src/tree/iter.rs index abae1ad..d812001 100644 --- a/src/tree/iter.rs +++ b/src/tree/iter.rs @@ -1,4 +1,4 @@ -use crate::{Node, operator::Operator}; +use crate::{operator::Operator, Node}; use std::slice::{Iter, IterMut}; /// An iterator that traverses an operator tree in pre-order. @@ -49,7 +49,7 @@ pub struct OperatorIterMut<'a> { impl<'a> OperatorIterMut<'a> { fn new(node: &'a mut Node) -> Self { OperatorIterMut { - stack: vec![node.children.iter_mut()] + stack: vec![node.children.iter_mut()], } } } @@ -92,4 +92,3 @@ impl Node { OperatorIterMut::new(self) } } - diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 35a3f96..5580031 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -98,12 +98,13 @@ impl Node { /// assert_eq!(iter.next(), None); /// ``` pub fn iter_identifiers_mut(&mut self) -> impl Iterator { - self.iter_operator_mut().filter_map(|operator| match operator { - Operator::VariableIdentifierWrite { identifier } - | Operator::VariableIdentifierRead { identifier } - | Operator::FunctionIdentifier { identifier } => Some(identifier), - _ => None - }) + self.iter_operator_mut() + .filter_map(|operator| match operator { + Operator::VariableIdentifierWrite { identifier } + | Operator::VariableIdentifierRead { identifier } + | Operator::FunctionIdentifier { identifier } => Some(identifier), + _ => None, + }) } /// Returns an iterator over all variable identifiers in this expression. @@ -152,11 +153,12 @@ impl Node { /// assert_eq!(iter.next(), None); /// ``` pub fn iter_variable_identifiers_mut(&mut self) -> impl Iterator { - self.iter_operator_mut().filter_map(|operator| match operator { - Operator::VariableIdentifierWrite { identifier } - | Operator::VariableIdentifierRead { identifier } => Some(identifier), - _ => None, - }) + self.iter_operator_mut() + .filter_map(|operator| match operator { + Operator::VariableIdentifierWrite { identifier } + | Operator::VariableIdentifierRead { identifier } => Some(identifier), + _ => None, + }) } /// Returns an iterator over all read variable identifiers in this expression. @@ -205,10 +207,11 @@ impl Node { /// assert_eq!(iter.next(), None); /// ``` pub fn iter_read_variable_identifiers_mut(&mut self) -> impl Iterator { - self.iter_operator_mut().filter_map(|operator| match operator { - Operator::VariableIdentifierRead { identifier } => Some(identifier), - _ => None, - }) + self.iter_operator_mut() + .filter_map(|operator| match operator { + Operator::VariableIdentifierRead { identifier } => Some(identifier), + _ => None, + }) } /// Returns an iterator over all write variable identifiers in this expression. @@ -255,10 +258,11 @@ impl Node { /// assert_eq!(iter.next(), None); /// ``` pub fn iter_write_variable_identifiers_mut(&mut self) -> impl Iterator { - self.iter_operator_mut().filter_map(|operator| match operator { - Operator::VariableIdentifierWrite { identifier } => Some(identifier), - _ => None, - }) + self.iter_operator_mut() + .filter_map(|operator| match operator { + Operator::VariableIdentifierWrite { identifier } => Some(identifier), + _ => None, + }) } /// Returns an iterator over all function identifiers in this expression. @@ -305,10 +309,11 @@ impl Node { /// assert_eq!(iter.next(), None); /// ``` pub fn iter_function_variable_identifiers_mut(&mut self) -> impl Iterator { - self.iter_operator_mut().filter_map(|operator| match operator { - Operator::FunctionIdentifier { identifier } => Some(identifier), - _ => None, - }) + self.iter_operator_mut() + .filter_map(|operator| match operator { + Operator::FunctionIdentifier { identifier } => Some(identifier), + _ => None, + }) } /// Evaluates the operator tree rooted at this node with the given context.