Macro mz_transform::transforms

source ·
macro_rules! transforms {
    (@op fill $buf:ident with $transform:expr; if $cond:expr, $($transforms:tt)*) => { ... };
    (@op fill $buf:ident with $transform:expr, $($transforms:tt)*) => { ... };
    (@op fill $buf:ident with) => { ... };
    ($($transforms:tt)*) => { ... };
}
Expand description

Convenience macro for guarding transforms behind a feature flag.

If you have a code block like

vec![
    Box::new(Foo::default()),
    Box::new(Bar::default()),
    Box::new(Baz::default()),
]

and you want to guard Bar behind a feature flag enable_bar, you can write

transforms![
    Box::new(Foo::default()),
    Box::new(Bar::default()); if ctx.features.enable_bar,
    Box::new(Baz::default()),
]

as a shorthand and in order to minimize your code diff.