const_guards 0.1.3

An attribute macro for compile time constraints on const generics
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
extern crate const_guards;
use const_guards::guard;

fn main() {
    f::<(), 1>();
}

#[guard(N > 0)]
pub fn f<T, const N: usize>() -> [T; N]
where
    T: Default + Copy,
{
    [T::default(); N]
}