mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
replace loop with iterators
This commit is contained in:
parent
86a7ac2d31
commit
b642e6c645
1 changed files with 7 additions and 6 deletions
|
@ -148,14 +148,15 @@ impl<'a, S: Sink> EventProcessor<'a, S> {
|
||||||
}
|
}
|
||||||
Event::Token {
|
Event::Token {
|
||||||
kind,
|
kind,
|
||||||
mut n_raw_tokens,
|
n_raw_tokens,
|
||||||
} => {
|
} => {
|
||||||
self.eat_ws();
|
self.eat_ws();
|
||||||
let mut len = 0.into();
|
let n_raw_tokens = n_raw_tokens as usize;
|
||||||
for _ in 0..n_raw_tokens {
|
let len = self.tokens[self.token_pos..self.token_pos + n_raw_tokens]
|
||||||
len += self.tokens[self.token_pos].len;
|
.iter()
|
||||||
}
|
.map(|it| it.len)
|
||||||
self.leaf(kind, len, n_raw_tokens as usize);
|
.sum::<TextUnit>();
|
||||||
|
self.leaf(kind, len, n_raw_tokens);
|
||||||
}
|
}
|
||||||
Event::Error { msg } => self.sink.error(msg, self.text_pos),
|
Event::Error { msg } => self.sink.error(msg, self.text_pos),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue