Macro const_eval_select
macro const_eval_select {
(
@capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty = $val:expr),* $(,)? } $( -> $ret:ty )? :
if const
$(#[$compiletime_attr:meta])* $compiletime:block
else
$(#[$runtime_attr:meta])* $runtime:block
) => { ... },
(
@capture$([$($binders:tt)*])? { $($arg:ident : $ty:ty),* $(,)? } $( -> $ret:ty )? :
if const
$(#[$compiletime_attr:meta])* $compiletime:block
else
$(#[$runtime_attr:meta])* $runtime:block
) => { ... },
}
A macro to make it easier to invoke const_eval_select. Use as follows:
const_eval_select!
The @capture block declares which surrounding variables / expressions can be
used inside the if const.
Note that the two arms of this if really each become their own function, which is why the
macro supports setting attributes for those functions. Both functions are marked as #[inline].
See [const_eval_select()] for the rules and requirements around that intrinsic.