-
-
Save The0x539/5ee18715cc3ce4a174aa16d7c2f65f20 to your computer and use it in GitHub Desktop.
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
use enum_dispatch::enum_dispatch; | |
#[enum_dispatch] | |
pub trait Acceptor { | |
fn accept(&self) {} | |
} | |
macro_rules! define_node { | |
( | |
$node:ident; | |
$( | |
$category:ident { $($variant:ident),* } | |
)* | |
) => { | |
pub enum $node { $($category($category)),* } | |
$( | |
#[enum_dispatch(Acceptor)] | |
pub enum $category { $($variant($variant)),* } | |
)* | |
} | |
} | |
define_node! { | |
NodeEnum; | |
Branch { Redirection } | |
} | |
pub struct Redirection {} | |
impl Acceptor for Redirection {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment