Skip to content

Commit 6967a85

Browse files
authored
Rollup merge of #145722 - Qelxiros:112815-tokenstream-extend, r=dtolnay
implement Extend<{Group, Literal, Punct, Ident}> for TokenStream Tracking issue: #112815
2 parents 486fae1 + ff7081e commit 6967a85

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

library/proc_macro/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,21 @@ impl Extend<TokenStream> for TokenStream {
376376
}
377377
}
378378

379+
macro_rules! extend_items {
380+
($($item:ident)*) => {
381+
$(
382+
#[stable(feature = "token_stream_extend_tt_items", since = "CURRENT_RUSTC_VERSION")]
383+
impl Extend<$item> for TokenStream {
384+
fn extend<T: IntoIterator<Item = $item>>(&mut self, iter: T) {
385+
self.extend(iter.into_iter().map(TokenTree::$item));
386+
}
387+
}
388+
)*
389+
};
390+
}
391+
392+
extend_items!(Group Literal Punct Ident);
393+
379394
/// Public implementation details for the `TokenStream` type, such as iterators.
380395
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
381396
pub mod token_stream {

0 commit comments

Comments
 (0)