1 个不稳定版本
0.1.0 | 2022年6月24日 |
---|
#7 in #predicates
5KB
53 行
一窥 const 泛型未来可能实现的功能
#![feature(generic_const_exprs)]
use generic_predicates::generic_predicates;
generic_predicates! {
pub fn foo<const N: usize>()
where
(N > 23, "`N` must be greater than 23")
{
}
}
fn main() {
// This compiles.
foo::<24>();
// This doesn't.
foo::<23>();
}
lib.rs
:
一窥 const 泛型未来可能实现的功能。
#![feature(generic_const_exprs)]
use generic_predicates::generic_predicates;
generic_predicates! {
pub fn foo<const N: usize>()
where
(N > 23, "`N` must be greater than 23")
{
}
}
fn main() {
// This compiles.
foo::<24>();
// This doesn't.
foo::<23>();
}
依赖项
~1.5MB
~36K SLoC