Created
June 2, 2023 11:33
-
-
Save jaredh159/827158c860aecf1a9b815b8677c7bf6e to your computer and use it in GitHub Desktop.
asciidork rust snippets while prototyping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #[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