diff options
author | Geoff Levand <geoff@infradead.org> | 2023-06-26 08:17:16 -0500 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2023-06-26 08:17:16 -0500 |
commit | 98ec4e7cee0f26a1af070ffc697d82c0f2714848 (patch) | |
tree | ae7176bc5d6ad1cc65476e71e98142b91450956d /rust/macros/helpers.rs | |
parent | 917ca4e843ee2239821d891825ec4f121f97caa4 (diff) | |
parent | 84506709c1c3fcb2422eeee9e99fc93dffbaf289 (diff) | |
download | ps3-linux-master.tar.gz |
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'rust/macros/helpers.rs')
-rw-r--r-- | rust/macros/helpers.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/rust/macros/helpers.rs b/rust/macros/helpers.rs index cf7ad950dc1e24..b2bdd4d8c958af 100644 --- a/rust/macros/helpers.rs +++ b/rust/macros/helpers.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 -use proc_macro::{token_stream, TokenTree}; +use proc_macro::{token_stream, Group, TokenTree}; pub(crate) fn try_ident(it: &mut token_stream::IntoIter) -> Option<String> { if let Some(TokenTree::Ident(ident)) = it.next() { @@ -56,6 +56,14 @@ pub(crate) fn expect_string_ascii(it: &mut token_stream::IntoIter) -> String { string } +pub(crate) fn expect_group(it: &mut token_stream::IntoIter) -> Group { + if let TokenTree::Group(group) = it.next().expect("Reached end of token stream for Group") { + group + } else { + panic!("Expected Group"); + } +} + pub(crate) fn expect_end(it: &mut token_stream::IntoIter) { if it.next().is_some() { panic!("Expected end"); |