Skip to content
Snippets Groups Projects
Commit cc1b1bc1 authored by Annabella Gethke's avatar Annabella Gethke
Browse files

Added mutable children function

parent f08bc536
No related branches found
No related tags found
No related merge requests found
...@@ -90,7 +90,8 @@ impl<T> SyntaxTree<T> { ...@@ -90,7 +90,8 @@ impl<T> SyntaxTree<T> {
if predicate(self) { if predicate(self) {
return Some(self) return Some(self)
} else { } else {
for child in &mut self.children{ let mut children = self.children_mut();
for child in children{
if(child.find_node_mut(predicate).is_some()){ if(child.find_node_mut(predicate).is_some()){
return child.find_node_mut(predicate); return child.find_node_mut(predicate);
} }
...@@ -113,6 +114,10 @@ impl<T> SyntaxTree<T> { ...@@ -113,6 +114,10 @@ impl<T> SyntaxTree<T> {
pub fn children(&self) -> &Vec<SyntaxTree<T>> { pub fn children(&self) -> &Vec<SyntaxTree<T>> {
&self.children &self.children
} }
pub fn children_mut(&mut self) -> &mut Vec<SyntaxTree<T>> {
&mut self.children
}
} }
impl<T: Display> SyntaxTree<T> { impl<T: Display> SyntaxTree<T> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment