Created
August 8, 2019 10:22
-
-
Save madprops/b4da3dc21954fe9e23ae190ce8712bd3 to your computer and use it in GitHub Desktop.
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_export] | |
macro_rules! hashmap | |
{ | |
($( $key: expr => $val: expr ),*) => {{ | |
let mut map = ::std::collections::HashMap::new(); | |
$( map.insert($key, $val); )* | |
map | |
}} | |
} | |
#[macro_export] | |
macro_rules! p | |
{ | |
($left:expr, $right:expr) => | |
{ | |
println!($left, $right); | |
}; | |
($left:expr) => | |
{ | |
println!("{}", $left); | |
} | |
} | |
#[macro_export] | |
macro_rules! pp | |
{ | |
($left:expr, $right:expr) => | |
{ | |
print!($left, $right); | |
}; | |
($left:expr) => | |
{ | |
print!("{}", $left); | |
} | |
} | |
#[macro_export] | |
macro_rules! e | |
{ | |
($left:expr, $right:expr) => | |
{ | |
eprintln!($left, $right); | |
}; | |
($left:expr) => | |
{ | |
eprintln!($left); | |
} | |
} | |
#[macro_export] | |
macro_rules! s | |
{ | |
($s: expr) => | |
{ | |
$s.to_string() | |
}; | |
() => | |
{ | |
String::new() | |
} | |
} | |
#[macro_export] | |
macro_rules! d | |
{ | |
($left:expr) => | |
{ | |
dbg!($left); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment