I want to push elements to a vector by operating on a constant string using a loop at compile time. nightly rust
is fine and I know about build.rs
. The question is two folds:
- Is there any way of using for loops to loop over the constant string in
const fn
? If not, is there any elegant/fast alternative? - How do I initiate an empty vector/iterator and add elements to it at compile time? Normally I use
push
insidefor
loop. The vector will be then stored inside the binary and available to use when I want to run later on thus saving on precious runtime.
If storing vector inside the binary is possible through build.rs
at compile-time, then I will consider it as a viable solution.