comptime_if
Simple compile-time conditional code inclusion for Rust macros.
This crate provides the comptime_if! macro, which allows you to include or exclude code blocks
based on compile-time boolean expressions.
This macro is useful for macro_rules! macros that accepts boolean parameters, like this:
Syntax
The syntax for the comptime_if! macro is as follows:
comptime_if!
<condition>: A boolean expression that can include variables, logical operators and parentheses. You can omit the parentheses if the condition is a single variable or a negation of a single variable. Supported operators are:&&,&(logical AND)||,|(logical OR)^(logical XOR)==(logical EQUAL)!=(logical NOT EQUAL)!(logical NOT)- Parentheses
(and)for grouping
<variable assignments>: A comma-separated list of variable assignments in the form<variable> = <boolean value>. Multiple assignments to the same variable will use the last assignment.
Example
use comptime_if;
comptime_if!
comptime_if!