diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-09-06 16:45:58 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-09-06 17:12:07 +1000 |
| commit | 42dbc72d7bb0645292d72816d768d1f5365a58ca (patch) | |
| tree | 45d037636391edfe45fb34e5598a27177690d85f /compiler | |
| parent | 58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2 (diff) | |
| download | rust-42dbc72d7bb0645292d72816d768d1f5365a58ca.tar.gz rust-42dbc72d7bb0645292d72816d768d1f5365a58ca.zip | |
Adjust `to_attr_token_stream`.
It uses `once` chained with `(0..self.num_calls).map(...)` followed by `.take(self.num_calls`. I found this hard to read. It's simpler to just use `repeat_with`.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr_wrapper.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index 5d6c574baa6..c4e8d9006e6 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -106,7 +106,7 @@ impl ToAttrTokenStream for LazyAttrTokenStreamImpl { let mut cursor_snapshot = self.cursor_snapshot.clone(); let tokens = std::iter::once((FlatToken::Token(self.start_token.0.clone()), self.start_token.1)) - .chain((0..self.num_calls).map(|_| { + .chain(std::iter::repeat_with(|| { let token = cursor_snapshot.next(); (FlatToken::Token(token.0), token.1) })) |
