Crate static_assert_macro [] [src]

A library implementation of so-called static_assert based on a macro which conditionally expands into an integer overflow, breaking the compilation.

It can take one or more constant boolean expressions as its parameters. When you have multiple conditions to verify, pass them to a single invocation of this macro as multiple parameters.

You cannot invoke this macro more than once in a given scope. This is because its implementation is based on a type synonym definition and two or more invocation causes name collision.

Example

#[macro_use]
extern crate static_assert_macro;

static_assert!(0 < 1, 1 < 2, 2 < 3);

fn main() {
    const FOUR: i32 = 4;
    static_assert!(1 + 2 == { FOUR - 1 });
}

Macros

static_assert