Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created October 5, 2022 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/dbf24574777089f896d62971f65a5ad6 to your computer and use it in GitHub Desktop.
Save rust-play/dbf24574777089f896d62971f65a5ad6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
macro_rules! run {
($a:expr) => {{
println!("{:?}", $a);
}};
}
#[derive(Debug)]
enum UiNode<'a> {
Window { content: &'a UiNode<'a> },
Column { content: Vec<UiNode<'a>> },
Label { text: &'a str },
Button { text: &'a str, on_click: fn() -> () },
}
fn main() {
fn on_button_click() {}
run! {
UiNode::Window {
content: &UiNode::Column {
content: vec![
UiNode::Label {
text: "Hello World"
},
UiNode::Button {
text: "Say Hi!",
on_click: on_button_click
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment