You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.1 KiB

use super::*;
/// Inherit imports from outer package.
#[macro_export] macro_rules! inherit {
() => {
#[allow(unused_imports)] use super::*;
};
}
/// Conditional compilation of code depending on if debug assertions are enabled.
#[macro_export] macro_rules! debug_if {
(if {$($debug:tt)*} else {$($prod:tt)*}) => {
cfg_if! {
if #[cfg(debug_assertions)] {
{ $($debug)* }
} else {
{ $($prod)* }
}
}
};
(if {$($debug:tt)*}) => {
debug_if!(if {$($debug)*} else {})
};
(else {$($prod:tt)*}) => {
debug_if!(if {} else {$($prod)*})
};
}
fn _debug_if_test()
{
debug_if!{
if {
println!("Debug");
} else {
println!("Release");
}
}
debug_if!{
if {
println!("Debug 2");
}
}
debug_if!{
else {
println!("Release 2");
}
}
}
/// Do not compile the code in this block
#[macro_export] macro_rules! remove {
($($tt:tt)*) => {
const _:() = {
$($tt)*
()
};
}
}
/// Show a compiler error message telling you the size in bytes of a type.
#[macro_export] macro_rules! show_size_of {
($t:ty) => (const _: [(); 0] = [(); ::core::mem::size_of::<$t>()];);
}