Skip to content

Commit f0fd9cd

Browse files
committed
implement Extend<{Group, Literal, Punct, Ident}> for TokenStream
1 parent 6ba0ce4 commit f0fd9cd

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
@@ -377,6 +377,21 @@ impl Extend<TokenStream> for TokenStream {
377377
}
378378
}
379379

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

0 commit comments

Comments
 (0)