Macro_rules to declare const array

I think I need a macro_rules! to declare a const param which is a 2D array of integers. Ideally I'd keep these parameters in external files and have the arrays built during compilation, e.g. for a file:

# params_1.txt
 1 2 3 4
 5 6 7 8
-1 2 3 4

I'd like to have a call:

declare_array_params!(PARAMS_1, "params_1.txt");

that would create a PARAMS_1 const.
I even made my first attempt, but it doesn't compile because:

`for` is not allowed in a `const`

Of course I use a for loop to parse the file. So is such a macro possible?

Using macro_rules? I don't think so. You could definitely do it with a procedural macro, though, which is effectively just normal Rust code that spits out code at compile time.

If you only have a limited set of parameter files, an even easier solution would be to use a build script.