Skip to content

Instantly share code, notes, and snippets.

@luser
Created August 28, 2018 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luser/0284cecdec8f7a2f789e37ffc52f963e to your computer and use it in GitHub Desktop.
Save luser/0284cecdec8f7a2f789e37ffc52f963e to your computer and use it in GitHub Desktop.
#![allow(unused)]
#![feature(macro_at_most_once_rep)]
macro_rules! opt {
(pub $($n:ident $( ($t:ty) )? ,)+) => {
enum Foo {
$( $n $( ($t) )?, )+
}
}
}
opt!{pub
A,
B(u32),
C(i32),
D,
}
fn main() {
let f = Foo::A;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment