diff options
author | Edwin Cheng <[email protected]> | 2019-04-22 08:33:55 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-04-22 08:33:55 +0100 |
commit | b177813f3bef708636ec4be271e376b111c36a59 (patch) | |
tree | f9272f478f1b943b4e643ed9bd2b5fd1ee2e7e8b /crates/ra_tt | |
parent | bbc5c1d24e1a641b134f634516828301e8cfc320 (diff) |
Add mbe expand limit and poision macro set
Diffstat (limited to 'crates/ra_tt')
-rw-r--r-- | crates/ra_tt/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 0b0b9b4d2..9cc646140 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs | |||
@@ -149,3 +149,15 @@ impl fmt::Display for Punct { | |||
149 | fmt::Display::fmt(&self.char, f) | 149 | fmt::Display::fmt(&self.char, f) |
150 | } | 150 | } |
151 | } | 151 | } |
152 | |||
153 | impl Subtree { | ||
154 | /// Count the number of tokens recursively | ||
155 | pub fn count(&self) -> usize { | ||
156 | self.token_trees.iter().fold(self.token_trees.len(), |acc, c| { | ||
157 | acc + match c { | ||
158 | TokenTree::Subtree(c) => c.count(), | ||
159 | _ => 0, | ||
160 | } | ||
161 | }) | ||
162 | } | ||
163 | } | ||