Rollup merge of #145722 - Qelxiros:112815-tokenstream-extend, r=dtolnay

implement Extend<{Group, Literal, Punct, Ident}> for TokenStream

Tracking issue: rust-lang/rust#112815
This commit is contained in:
dianqk 2025-10-11 07:05:54 +08:00 committed by GitHub
commit 6967a8561b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -376,6 +376,21 @@ impl Extend<TokenStream> 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<T: IntoIterator<Item = $item>>(&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 {