#assert #static #static-assert #testing

no-std sa

Simple Rust macro to assert constant expressions

3 stable releases

2.0.0 Dec 2, 2021
1.0.1 Apr 22, 2020
1.0.0 Apr 21, 2020

#353 in No standard library

23 downloads per month
Used in restbl

BSL-1.0 license

4KB

static-assert

Crates.io Documentation

Simple static_assert macro for compile time assertions.

Uses const_panic within const variable to produce compile error hence only usable in const context

Requirements

  • Rust 1.57

lib.rs:

Simple static_assert macro for compile time assertions

Uses const_panic within const variable to produce compile error hence only usable in const context.

Usage

use sa::static_assert;

static_assert!(1 == 1);
static_assert!(1 == 1, "Must be equal");
use sa::static_assert;

static_assert!(0 == 1, "Must be equal"); //should fail
use sa::static_assert;

static_assert!(0 == 1); //should fail

No runtime deps