Skip to content

Instantly share code, notes, and snippets.

@The0x539

The0x539/mre.rs Secret

Created March 18, 2024 22:29
Show Gist options
  • Save The0x539/5ee18715cc3ce4a174aa16d7c2f65f20 to your computer and use it in GitHub Desktop.
Save The0x539/5ee18715cc3ce4a174aa16d7c2f65f20 to your computer and use it in GitHub Desktop.
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