Constable
Generate lookup tables at compile time using attribute macros on const functions.
Example
const
The code gets expanded to an inner function definition and building a const lookup table. (note the example below is simplified and not valid const code)
const
Also in cases where the return value is a bool, the table is bit-packed so that the lookup table takes up less memory (and therefore more cache efficient).
$ cargo bench --bench bench
Finished `bench` profile [optimized] target(s) in 0.03s
Running benches/bench.rs (target/release/deps/bench-ad4b147a8cee6c74)
Timer precision: 12 ns
bench fastest │ slowest │ median │ mean │ samples │ iters
├─ computed 1.037 µs │ 10.51 µs │ 1.202 µs │ 1.656 µs │ 100 │ 200
╰─ lookup_table 672.7 ns │ 10.1 µs │ 772.7 ns │ 1.191 µs │ 100 │ 200
Note that the fastest for computed and lookup_table are different units.