Allow , to delimit macro 2.0 rules

This commit is contained in:
Jonas Schievink 2021-04-03 03:08:31 +02:00
parent eb264fb819
commit eaffdae300
3 changed files with 30 additions and 2 deletions

View file

@ -34,6 +34,17 @@ impl<'a> TtIter<'a> {
}
}
pub(crate) fn expect_any_char(&mut self, chars: &[char]) -> Result<(), ()> {
match self.next() {
Some(tt::TokenTree::Leaf(tt::Leaf::Punct(tt::Punct { char: c, .. })))
if chars.contains(c) =>
{
Ok(())
}
_ => Err(()),
}
}
pub(crate) fn expect_subtree(&mut self) -> Result<&'a tt::Subtree, ()> {
match self.next() {
Some(tt::TokenTree::Subtree(it)) => Ok(it),