Skip to content

Instantly share code, notes, and snippets.

@sam0x17
Created December 19, 2022 06:29
Show Gist options
  • Save sam0x17/34ddc2eeac99753a3370e610b3c5e993 to your computer and use it in GitHub Desktop.
Save sam0x17/34ddc2eeac99753a3370e610b3c5e993 to your computer and use it in GitHub Desktop.
bare block parsing implementation using syn (parse the contents of a block without braces)
struct BareBlock {
stmts: Vec<Stmt>,
}
impl Parse for BareBlock {
fn parse(input: ParseStream) -> syn::Result<Self> {
match Block::parse_within(input) {
Ok(stmts) => Ok(BareBlock { stmts }),
Err(e) => Err(e),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment