| Crates.io | constify |
| lib.rs | constify |
| version | 0.0.1 |
| created_at | 2026-01-20 23:34:47.459964+00 |
| updated_at | 2026-01-20 23:34:47.459964+00 |
| description | A procedural macro for basic static specialization. |
| homepage | https://github.com/DGriffin91/egui_software_backend |
| repository | https://github.com/DGriffin91/egui_software_backend |
| max_upload_size | |
| id | 2057848 |
| size | 11,550 |
Example usage:
#[constify]
fn foo(
#[constify] a: bool,
#[constify] b: bool,
c: bool
) -> u32 {
let mut sum = 0;
if a {
sum += 1;
}
if b {
sum += 10;
}
if c {
sum += 100;
}
sum
}
Expansion:
#[inline(always)]
fn foo(a: bool, b: bool, c: bool) -> u32 {
fn foo<const a: bool, const b: bool>(c: bool) -> u32 {
let mut sum = 0;
if a {
sum += 1;
}
if b {
sum += 10;
}
if c {
sum += 100;
}
sum
}
match (a, b) {
(false, false) => foo::<false, false>(c),
(true, false) => foo::<true, false>(c),
(false, true) => foo::<false, true>(c),
(true, true) => foo::<true, true>(c),
}
}
Inspired by https://github.com/TennyZhuang/const-currying-rs