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

macro car

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

3 releases

0.1.2 Feb 7, 2025
0.1.1 Jul 14, 2024
0.1.0 Mar 29, 2024

#1768 in Procedural macros

Download history 1/week @ 2024-10-30 1/week @ 2024-11-06 2/week @ 2024-11-13 5/week @ 2024-11-20 4/week @ 2024-11-27 21/week @ 2024-12-04 29/week @ 2024-12-11 12/week @ 2024-12-18 21/week @ 2025-01-01 7/week @ 2025-01-08 4/week @ 2025-01-15 8/week @ 2025-01-22 16/week @ 2025-01-29 158/week @ 2025-02-05

188 downloads per month
Used in dib

MIT license

9KB
156 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

~205–640KB
~15K SLoC