diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_tt/src/lib.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 9cc646140..62c5ac52a 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs | |||
@@ -153,11 +153,15 @@ impl fmt::Display for Punct { | |||
153 | impl Subtree { | 153 | impl Subtree { |
154 | /// Count the number of tokens recursively | 154 | /// Count the number of tokens recursively |
155 | pub fn count(&self) -> usize { | 155 | pub fn count(&self) -> usize { |
156 | self.token_trees.iter().fold(self.token_trees.len(), |acc, c| { | 156 | let children_count = self |
157 | acc + match c { | 157 | .token_trees |
158 | .iter() | ||
159 | .map(|c| match c { | ||
158 | TokenTree::Subtree(c) => c.count(), | 160 | TokenTree::Subtree(c) => c.count(), |
159 | _ => 0, | 161 | _ => 0, |
160 | } | 162 | }) |
161 | }) | 163 | .sum::<usize>(); |
164 | |||
165 | self.token_trees.len() + children_count | ||
162 | } | 166 | } |
163 | } | 167 | } |