aboutsummaryrefslogtreecommitdiff
path: root/src/algo
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-31 13:40:40 +0100
committerAleksey Kladov <[email protected]>2018-07-31 13:40:40 +0100
commit9ce7e8110254e8db476c96bce2eecb2d16983159 (patch)
treeabaddbafc4593948849394b430e3bde5c624fa22 /src/algo
parent2a2815266b35de12bd3c48cc405e8b3e8fcf8885 (diff)
cleanups
Diffstat (limited to 'src/algo')
-rw-r--r--src/algo/walk.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/algo/walk.rs b/src/algo/walk.rs
index 86dd82cc9..c6d050251 100644
--- a/src/algo/walk.rs
+++ b/src/algo/walk.rs
@@ -1,6 +1,6 @@
1use SyntaxNodeRef; 1use SyntaxNodeRef;
2 2
3pub fn preorder<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item=SyntaxNodeRef<'a>> { 3pub fn preorder<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item = SyntaxNodeRef<'a>> {
4 walk(root).filter_map(|event| match event { 4 walk(root).filter_map(|event| match event {
5 WalkEvent::Enter(node) => Some(node), 5 WalkEvent::Enter(node) => Some(node),
6 WalkEvent::Exit(_) => None, 6 WalkEvent::Exit(_) => None,
@@ -13,7 +13,7 @@ enum WalkEvent<'a> {
13 Exit(SyntaxNodeRef<'a>), 13 Exit(SyntaxNodeRef<'a>),
14} 14}
15 15
16fn walk<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item=WalkEvent<'a>> { 16fn walk<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item = WalkEvent<'a>> {
17 let mut done = false; 17 let mut done = false;
18 ::itertools::unfold(WalkEvent::Enter(root), move |pos| { 18 ::itertools::unfold(WalkEvent::Enter(root), move |pos| {
19 if done { 19 if done {
@@ -35,7 +35,7 @@ fn walk<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item=WalkEvent<'a>> {
35 None => match node.parent() { 35 None => match node.parent() {
36 Some(node) => WalkEvent::Exit(node), 36 Some(node) => WalkEvent::Exit(node),
37 None => WalkEvent::Exit(node), 37 None => WalkEvent::Exit(node),
38 } 38 },
39 } 39 }
40 } 40 }
41 } 41 }
@@ -43,4 +43,3 @@ fn walk<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item=WalkEvent<'a>> {
43 Some(res) 43 Some(res)
44 }) 44 })
45} 45}
46