Skip to content

Commit 1baff31

Browse files
committed
Add new TokenStream Extend impls
1 parent 6f45ba0 commit 1baff31

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,31 @@ impl Extend<TokenStream> for TokenStream {
304304
}
305305
}
306306

307+
impl Extend<Group> for TokenStream {
308+
fn extend<I: IntoIterator<Item = Group>>(&mut self, tokens: I) {
309+
self.inner.extend(tokens.into_iter().map(TokenTree::Group));
310+
}
311+
}
312+
313+
impl Extend<Ident> for TokenStream {
314+
fn extend<I: IntoIterator<Item = Ident>>(&mut self, tokens: I) {
315+
self.inner.extend(tokens.into_iter().map(TokenTree::Ident));
316+
}
317+
}
318+
319+
impl Extend<Punct> for TokenStream {
320+
fn extend<I: IntoIterator<Item = Punct>>(&mut self, tokens: I) {
321+
self.inner.extend(tokens.into_iter().map(TokenTree::Punct));
322+
}
323+
}
324+
325+
impl Extend<Literal> for TokenStream {
326+
fn extend<I: IntoIterator<Item = Literal>>(&mut self, tokens: I) {
327+
self.inner
328+
.extend(tokens.into_iter().map(TokenTree::Literal));
329+
}
330+
}
331+
307332
/// Collects a number of token trees into a single stream.
308333
impl FromIterator<TokenTree> for TokenStream {
309334
fn from_iter<I: IntoIterator<Item = TokenTree>>(tokens: I) -> Self {

0 commit comments

Comments
 (0)