Skip to content

Commit

Permalink
Check no remaining token after the first literal
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 2, 2023
1 parent 258e9e8 commit 137ae33
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/test_lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ use std::str::FromStr;
use syn::{Lit, LitFloat, LitInt, LitStr};

fn lit(s: &str) -> Lit {
match TokenStream::from_str(s)
.unwrap()
.into_iter()
.next()
.unwrap()
{
TokenTree::Literal(lit) => Lit::new(lit),
let mut tokens = TokenStream::from_str(s).unwrap().into_iter();
match tokens.next().unwrap() {
TokenTree::Literal(lit) => {
assert!(tokens.next().is_none());
Lit::new(lit)
}
_ => panic!(),
}
}
Expand Down

0 comments on commit 137ae33

Please sign in to comment.