Array creation at compile time

At compile time, Is it possible in Rust to to compute elements for an array|vec of constant integer values that can be used at runtime within various functions?

I can do this in some other languages, and want to see if this will speedup an algorithm that currently compute these arrays each time at runtime. The arrays can be fairly large in certain situations.

This is more to help me learn Rust at a deeper level and compare it to some other languages.

Arrays yes, but Vec no. Use of const functions is still pretty limited.

Since the arrays are large, one approach is to declare const arrays, which would go into the data segment. Then create Vecs at runtime from those arrays, if you need to mutate them; however, this will copy them to the heap.

You can't guarantee a compile time computation for these use cases, but if your values are really constant, it's likely that LLVM's const propagation will evaluate them anyway. Also, you could always write a proc macro. Those can do anything at compile time. They can't interact with the types of the calling code, but computing an array of constants likely doesn't require it.