Macro cli_toolbox::release [−][src]
macro_rules! release { ($expr : expr) => { ... }; (QUITE $expr : expr) => { ... }; (TERSE $expr : expr) => { ... }; (VERBOSE $expr : expr) => { ... }; (TERSE $terse_expr : expr ; VERBOSE $verbose_expr : expr ;) => { ... }; ($stmt : stmt) => { ... }; (QUITE => $stmt : stmt) => { ... }; (TERSE => $stmt : stmt) => { ... }; (VERBOSE => $stmt : stmt) => { ... }; (TERSE => $terse_expr : stmt, VERBOSE => $verbose_expr : stmt) => { ... }; }
Expand description
The release!
macro provides release only conditional code evaluation
according to Verbosity
level.
Features
-
you can evaluate code according to level of verbosity, i.e.
Quite
,Terse
orVerbose
-
all
Terse
evaluations will also evaluate if the level is set toVerbose
-
you can choose unique code evaluations for
Terse
orVerbose
individually
Basic Example
Unconditionally evaluates statement in release build.
release! {{ do_something_profound(); }} fn do_something_profound() { cfg_if! { if #[cfg(not(debug_assertions))] { /* i will not explode today */ } else { panic!("you didn't wear your peril sensitive glasses, did you?"); } } }
Conditional Examples
Conditionally evaluate statement or expression in release build.
Quite
Verbosity::Terse.set_as_global(); // will only evaluate in release and level at quite release! { QUITE => { shhhh(); } } fn shhhh() { panic!("poof!"); }
Terse
Verbosity::Quite.set_as_global(); // will only evaluate in release and level at terse or verbose release! { TERSE => { henny_penny(); } } fn henny_penny() { panic!("the sky is falling!!!"); }
Verbose
Verbosity::Terse.set_as_global(); // will only evaluate in release and level at verbose release! { VERBOSE => { kaboom(); } } fn kaboom() { panic!("pop goes the, pop goes the windin of the weasel"); }
Terse
orVerbose
Verbosity::Quite.set_as_global(); // will only evaluate in release and level at verbose release! { TERSE => { henny_penny(); }, VERBOSE => { kaboom(); } } fn henny_penny() { panic!("the sky is falling!!!"); } fn kaboom() { panic!("pop goes the, pop goes the windin of the weasel"); }