diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 162b4fdcc8ae2..97dc482689781 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -377,6 +377,21 @@ impl Extend for TokenStream { } } +macro_rules! extend_items { + ($($item:ident)*) => { + $( + #[stable(feature = "token_stream_extend_tt_items", since = "CURRENT_RUSTC_VERSION")] + impl Extend<$item> for TokenStream { + fn extend>(&mut self, iter: T) { + self.extend(iter.into_iter().map(TokenTree::$item)); + } + } + )* + }; +} + +extend_items!(Group Literal Punct Ident); + /// Public implementation details for the `TokenStream` type, such as iterators. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub mod token_stream {