Skip to content

Instantly share code, notes, and snippets.

@jaredh159
Created June 2, 2023 11:33
Show Gist options
  • Save jaredh159/827158c860aecf1a9b815b8677c7bf6e to your computer and use it in GitHub Desktop.
Save jaredh159/827158c860aecf1a9b815b8677c7bf6e to your computer and use it in GitHub Desktop.
asciidork rust snippets while prototyping
// #[macro_use]
macro_rules! block_struct {
($name: ident, $context: ident) => {
#[derive(Debug, PartialEq, Eq)]
pub struct $name {
pub blocks: Vec<Block>,
}
impl $name {
fn new() -> Self {
$name { blocks: vec![] }
}
fn context() -> Context {
Context::$context
}
}
};
}
block_struct!(ParagraphBlock, Paragraph);
block_struct!(ListingBlock, Listing);
block_struct!(PreambleBlock, Preamble);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment