Skip to content

Commit

Permalink
include only one variant in compiled code (#2438)
Browse files Browse the repository at this point in the history
  • Loading branch information
kziemianek committed Jan 29, 2024
1 parent 7503916 commit 7e9b430
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions primitives/core/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@

#[macro_export]
macro_rules! if_production_or {
($prod_variant:expr, $non_prod_variant:expr) => {
if cfg!(feature = "production") {
$prod_variant
} else {
($prod_variant:expr, $non_prod_variant:expr) => {{
#[cfg(not(feature = "production"))]
{
$non_prod_variant
}
};
#[cfg(feature = "production")]
{
$prod_variant
}
}};
}

#[macro_export]
macro_rules! if_not_production {
($expression:expr) => {
if cfg!(not(feature = "production")) {
#[cfg(not(feature = "production"))]
{
$expression
}
};
Expand Down

0 comments on commit 7e9b430

Please sign in to comment.