syn
syn copied to clipboard
Expose `AllowNoSemi`, add `Stmt::requires_terminator` and allow custom function to be passed to `Block::parse_within`
I want to write a macro that adds a special type of statement. Currently I need to re-implement the sym functionality.
It would make much easier if AllowNoSemi was exposed or Block::parse_within allowed custom function to be passed:
struct My {
Stmt(Stmt),
Custom(Custom),
}
impl RequiresTerminator {
fn requires_terminator(&self) -> bool {
match self {
My::Stmt(stmt) => stmt.requires_terminator(&self),
My::Custom(my) => my.requires_terminator(&self),
}
}
}
let r: Vec<My> = Block::call_within(input, |input| {
if input.peek(kw::my) {
My::Custom(input.parse()?)
} else {
My::Stmt(input.parse()?)
}
});