I would like to have a Struct that contains a byte (u8) array where the length of that array is specified as parameter to the new function. Can this be done? Maybe using some crate?
The length is actually a constant defined through toml_cfg::toml_config, but I didn't find any way to pass that to a type generic of my struct, only as parameter to the new function...
I'd prefer to have an uninitialized stack allocated array to that easy but potentially less performant Vector solution...
Generics must be known at compile time, while your config will only be know when your program is running, so there's no way to use it for an array size. Consider instead using a Vec.
So my problem was that I've tried use generics to define my buffer's size, which need to be actual literals when instantiating them.
Getting rid of the generics part of my struct definition, importing the const/static? CONFIG struct like use crate::CONFIG;
And defining the buffer in my struct like: buffer: [u8; CONFIG.buffer_size],
solved my problem.