replace loop with iterators

This commit is contained in:
Aleksey Kladov 2018-10-08 15:46:14 +03:00
parent 86a7ac2d31
commit b642e6c645

View file

@ -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),
} }