Merge pull request #203 from dtolnay/parse

Optimize parse+extend to make only one proc macro bridge call
This commit is contained in:
David Tolnay 2021-12-27 19:02:25 -08:00 committed by GitHub
commit 0a04bae97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
use crate::{IdentFragment, ToTokens, TokenStreamExt};
use std::fmt;
use std::iter;
use std::ops::BitOr;
pub use proc_macro2::*;
@ -178,7 +179,7 @@ pub fn push_group_spanned(
pub fn parse(tokens: &mut TokenStream, s: &str) {
let s: TokenStream = s.parse().expect("invalid token stream");
tokens.extend(s);
tokens.extend(iter::once(s));
}
pub fn parse_spanned(tokens: &mut TokenStream, span: Span, s: &str) {