Skip to content

Commit

Permalink
Stream respan without collecting Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 4, 2020
1 parent 925f164 commit 379c4d4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/respan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ where
}

fn respan_tokens(tokens: TokenStream, span: Span) -> TokenStream {
let mut tokens = tokens.into_iter().collect::<Vec<_>>();
for token in tokens.iter_mut() {
token.set_span(span);
}
tokens.into_iter().collect()
tokens
.into_iter()
.map(|mut token| {
token.set_span(span);
token
})
.collect()
}

0 comments on commit 379c4d4

Please sign in to comment.