diff options
author | Aleksey Kladov <[email protected]> | 2018-10-08 13:46:14 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-08 13:46:14 +0100 |
commit | b642e6c6451b21d9b3fc719472a1802ea70a83d8 (patch) | |
tree | a8c8f2841b5188ffaf63d37d5181649295da48e3 /crates | |
parent | 86a7ac2d31e97c42a9da8d8fd539b5a0de0fa795 (diff) |
replace loop with iterators
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_syntax/src/parser_impl/event.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index 48f37c57c..4e6e25cfb 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs | |||
@@ -148,14 +148,15 @@ impl<'a, S: Sink> EventProcessor<'a, S> { | |||
148 | } | 148 | } |
149 | Event::Token { | 149 | Event::Token { |
150 | kind, | 150 | kind, |
151 | mut n_raw_tokens, | 151 | n_raw_tokens, |
152 | } => { | 152 | } => { |
153 | self.eat_ws(); | 153 | self.eat_ws(); |
154 | let mut len = 0.into(); | 154 | let n_raw_tokens = n_raw_tokens as usize; |
155 | for _ in 0..n_raw_tokens { | 155 | let len = self.tokens[self.token_pos..self.token_pos + n_raw_tokens] |
156 | len += self.tokens[self.token_pos].len; | 156 | .iter() |
157 | } | 157 | .map(|it| it.len) |
158 | self.leaf(kind, len, n_raw_tokens as usize); | 158 | .sum::<TextUnit>(); |
159 | self.leaf(kind, len, n_raw_tokens); | ||
159 | } | 160 | } |
160 | Event::Error { msg } => self.sink.error(msg, self.text_pos), | 161 | Event::Error { msg } => self.sink.error(msg, self.text_pos), |
161 | } | 162 | } |