cargo format

This commit is contained in:
Ben Weinstein-Raun 2023-06-02 19:00:42 -07:00 committed by ISibboI
parent d45cb7c420
commit 1646a070a9
2 changed files with 30 additions and 26 deletions

View File

@ -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)
}
}

View File

@ -98,11 +98,12 @@ impl Node {
/// assert_eq!(iter.next(), None);
/// ```
pub fn iter_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String> {
self.iter_operator_mut().filter_map(|operator| match operator {
self.iter_operator_mut()
.filter_map(|operator| match operator {
Operator::VariableIdentifierWrite { identifier }
| Operator::VariableIdentifierRead { identifier }
| Operator::FunctionIdentifier { identifier } => Some(identifier),
_ => None
_ => None,
})
}
@ -152,7 +153,8 @@ impl Node {
/// assert_eq!(iter.next(), None);
/// ```
pub fn iter_variable_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String> {
self.iter_operator_mut().filter_map(|operator| match operator {
self.iter_operator_mut()
.filter_map(|operator| match operator {
Operator::VariableIdentifierWrite { identifier }
| Operator::VariableIdentifierRead { identifier } => Some(identifier),
_ => None,
@ -205,7 +207,8 @@ impl Node {
/// assert_eq!(iter.next(), None);
/// ```
pub fn iter_read_variable_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String> {
self.iter_operator_mut().filter_map(|operator| match operator {
self.iter_operator_mut()
.filter_map(|operator| match operator {
Operator::VariableIdentifierRead { identifier } => Some(identifier),
_ => None,
})
@ -255,7 +258,8 @@ impl Node {
/// assert_eq!(iter.next(), None);
/// ```
pub fn iter_write_variable_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String> {
self.iter_operator_mut().filter_map(|operator| match operator {
self.iter_operator_mut()
.filter_map(|operator| match operator {
Operator::VariableIdentifierWrite { identifier } => Some(identifier),
_ => None,
})
@ -305,7 +309,8 @@ impl Node {
/// assert_eq!(iter.next(), None);
/// ```
pub fn iter_function_variable_identifiers_mut(&mut self) -> impl Iterator<Item = &mut String> {
self.iter_operator_mut().filter_map(|operator| match operator {
self.iter_operator_mut()
.filter_map(|operator| match operator {
Operator::FunctionIdentifier { identifier } => Some(identifier),
_ => None,
})