[][src]Crate static_assert_macro

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.

Prior to version 1.1, when you have multiple conditions to verify, you had to rely on the hack to pass them to a single invocation of the macro as multiple parameters because its implementation details prevented multiple invocations from coexisting in a single scope.

This limitation was removed in version 1.1; you can now call this macro an arbitrary number of times in a given scope.


// Rust 2015 syntax
extern crate static_assert_macro;

#[cfg(feature = "Rust 2018 syntax")]
use static_assert_macro::static_assert;

static_assert!(0 < 1);
static_assert!(1 < 2);
static_assert!(2 < 3, true || false);

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