daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Dec 11th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub struct DefaultParam<T> {
  2.     value: T,
  3.     name: &'static str,
  4. }
  5.  
  6. macro_rules! define {
  7.     ( $name:ident : $t:ty = $val:expr ) => {
  8.         pub const $name: DefaultParam<$t> = DefaultParam {
  9.             value: $val,
  10.             name: stringify!($val),
  11.         };
  12.     }
  13. }
  14.  
  15. define!(PORT: u32 = 1234);
  16.  
  17. fn main() {
  18.     println!("{} has the value: {}", PORT.name, PORT.value);
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top