const-reify 0.1.0

Safe runtime-to-const-generic dispatch via match tables
Documentation
  • Coverage
  • 100%
    20 out of 20 items documented14 out of 18 items with examples
  • Size
  • Source code size: 30.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.63 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 44s Average build duration of successful builds.
  • all releases: 44s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • joshburgess/reify-reflect
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • joshburgess

const-reify

Runtime-to-const-generic bridge via match-table dispatch.

Given a runtime u64 value in 0..=255, dispatches to the corresponding monomorphization of a const-generic type, enabling type-level programming with runtime-determined values.

See DESIGN.md for the design rationale and safety analysis.

Examples

use const_reify::{reify_const, HasModulus};

let result = reify_const(17, |m| m.modulus());
assert_eq!(result, 17);

Using the [reify!] macro:

use const_reify::{reify, HasModulus};

reify!(42u64, |m: &dyn HasModulus| {
    assert_eq!(m.modulus(), 42);
});