mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 09:11:35 +00:00
Handle the possibility that the class name is in its own Group (#2159)
* Handle the possibility that the class name is in its own Group rust-lang/rust#72388 makes this happen * Handle Groups in more places * fmt! * Add some functions to handle Groups As suggested by @alexcrichton [here](https://gist.github.com/alexcrichton/3c93ab2547d45d9caa3b72309cd4262b).
This commit is contained in:
@ -43,10 +43,7 @@ pub fn wasm_bindgen_test(
|
||||
}
|
||||
}
|
||||
}
|
||||
let ident = match body.next() {
|
||||
Some(TokenTree::Ident(token)) => token,
|
||||
_ => panic!("expected a function name"),
|
||||
};
|
||||
let ident = find_ident(&mut body).expect("expected a function name");
|
||||
|
||||
let mut tokens = Vec::<TokenTree>::new();
|
||||
|
||||
@ -78,3 +75,13 @@ pub fn wasm_bindgen_test(
|
||||
|
||||
tokens.into_iter().collect::<TokenStream>().into()
|
||||
}
|
||||
|
||||
fn find_ident(iter: &mut token_stream::IntoIter) -> Option<Ident> {
|
||||
match iter.next()? {
|
||||
TokenTree::Ident(i) => Some(i),
|
||||
TokenTree::Group(g) if g.delimiter() == Delimiter::None => {
|
||||
find_ident(&mut g.stream().into_iter())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user