#array #const #constant #map #macro #fn #from-fn

macro car

std::array::{map, from_fn, try_from_fn} in const

2 releases

0.1.1 Jul 14, 2024
0.1.0 Mar 29, 2024

#1616 in Procedural macros


Used in dib

MIT license

9KB
147 lines

car

macro based array manipulation constant techniques

you wanted a quick LUT in const? here you go!

// please note that this is in no way performant or a good idea.
let squares: [usize; 0xffffffff] = car::from_fn!(|i| i * 2);

completely stable!

for once!


lib.rs:

provides some (map and from_fn) core::array fn related functions as const macros.

const X: [usize; 6] = car::map!(car::from_fn!(|x| x), |x| x * 24);

Dependencies

~210–650KB
~15K SLoC