diff options
Diffstat (limited to 'third_party/rust/syn/src/verbatim.rs')
-rw-r--r-- | third_party/rust/syn/src/verbatim.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/third_party/rust/syn/src/verbatim.rs b/third_party/rust/syn/src/verbatim.rs new file mode 100644 index 0000000000..0686352f7a --- /dev/null +++ b/third_party/rust/syn/src/verbatim.rs @@ -0,0 +1,15 @@ +use crate::parse::{ParseBuffer, ParseStream}; +use proc_macro2::TokenStream; +use std::iter; + +pub fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream { + let end = end.cursor(); + let mut cursor = begin.cursor(); + let mut tokens = TokenStream::new(); + while cursor != end { + let (tt, next) = cursor.token_tree().unwrap(); + tokens.extend(iter::once(tt)); + cursor = next; + } + tokens +} |