How to excute code at compile time
There are three variants of this:
- Any code inside the definition of a
staticis guaranteed to run at compile time, but it can only use const methods, and you can't e.g. read files or do web requests.
- Proc-macros can execute arbitrary code during compilation.
- A build script can also be used, which is also able to execute arbitrary code.
In the above three methods which method is best for run the iteration loop at compile time?
The iteration loop?
Means for example while loop
What does it do? Just compute a value? Which type? Does it print stuff or write to a file?
Just compute a value
If you are able to put it in a
const, then do that.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.