Skip to content

Instantly share code, notes, and snippets.

@madprops
Created August 8, 2019 10:22
Show Gist options
  • Save madprops/b4da3dc21954fe9e23ae190ce8712bd3 to your computer and use it in GitHub Desktop.
Save madprops/b4da3dc21954fe9e23ae190ce8712bd3 to your computer and use it in GitHub Desktop.
#[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