Skip to content

Commit 7a024f2

Browse files
hoshinolinajannau
authored andcommitted
*RFL import: macros::module params functionality & deps
Commit reference: 3dfc5eb
1 parent 8352c3d commit 7a024f2

2 files changed

Lines changed: 354 additions & 1 deletion

File tree

rust/macros/helpers.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ pub(crate) fn expect_string_ascii(it: &mut token_stream::IntoIter) -> String {
5656
string
5757
}
5858

59+
pub(crate) fn expect_literal(it: &mut token_stream::IntoIter) -> String {
60+
try_literal(it).expect("Expected Literal")
61+
}
62+
5963
pub(crate) fn expect_group(it: &mut token_stream::IntoIter) -> Group {
6064
if let TokenTree::Group(group) = it.next().expect("Reached end of token stream for Group") {
6165
group
@@ -215,3 +219,19 @@ pub(crate) fn parse_generics(input: TokenStream) -> (Generics, Vec<TokenTree>) {
215219
rest,
216220
)
217221
}
222+
223+
pub(crate) fn get_literal(it: &mut token_stream::IntoIter, expected_name: &str) -> String {
224+
assert_eq!(expect_ident(it), expected_name);
225+
assert_eq!(expect_punct(it), ':');
226+
let literal = expect_literal(it);
227+
assert_eq!(expect_punct(it), ',');
228+
literal
229+
}
230+
231+
pub(crate) fn get_string(it: &mut token_stream::IntoIter, expected_name: &str) -> String {
232+
assert_eq!(expect_ident(it), expected_name);
233+
assert_eq!(expect_punct(it), ':');
234+
let string = expect_string(it);
235+
assert_eq!(expect_punct(it), ',');
236+
string
237+
}

0 commit comments

Comments
 (0)