Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct DefaultParam<T> {
- value: T,
- name: &'static str,
- }
- macro_rules! define {
- ( $name:ident : $t:ty = $val:expr ) => {
- pub const $name: DefaultParam<$t> = DefaultParam {
- value: $val,
- name: stringify!($val),
- };
- }
- }
- define!(PORT: u32 = 1234);
- fn main() {
- println!("{} has the value: {}", PORT.name, PORT.value);
- }
Add Comment
Please, Sign In to add comment