-
-
Save rust-play/dbf24574777089f896d62971f65a5ad6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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_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