macro_rules! dev_only {
($($body:tt)*) => { ... };
}Expand description
Runs body only in a build that compiles in development diagnostics.
Expands to if DEV { body }. Because DEV is a const, a release build folds the branch
away and drops body with it, including any message strings and bookkeeping it alone
references.
body is type-checked in every mode. That is the point: a diagnostic that only compiles on
one profile rots, and the rot surfaces as a broken release build. The cost is that body may
not reference items that themselves exist only in a dev build.
ยงExamples
use retroglyph_core::dev_only;
let sprite_px = (32, 32);
let cell_px = (16, 16);
dev_only!({
if sprite_px > cell_px {
warn_overflow(sprite_px, cell_px);
}
});The block form is not required; any statements work.
dev_only!(misses += 1;);