generic_predicates/lib.rs
1//! A taste of what const generics could enable in the future.
2//!
3//! ```rust,no_run
4//! #![feature(generic_const_exprs)]
5//!
6//! use generic_predicates::generic_predicates;
7//!
8//! generic_predicates! {
9//! pub fn foo<const N: usize>()
10//! where
11//! (N > 23, "`N` must be greater than 23")
12//! {
13//!
14//! }
15//! }
16//!
17//! fn main() {
18//! // This compiles.
19//! foo::<24>();
20//!
21//! // This doesn't.
22//! foo::<23>();
23//! }
24//! ```
25
26pub use generic_predicates_macro::generic_predicates;
27
28pub mod __private {
29 pub const fn assertion(predicate: bool, msg: &'static str) -> usize {
30 assert!(predicate, "{}", msg);
31 0
32 }
33}