Hacker News new | ask | show | jobs
by thehappypm 1100 days ago
I’m not a Rustacean, but it seems much easier to pre compute, store in a file, then load the file at startup
2 comments

In rust you can also pre-compute (optionally at build time in the build.rs) and load the file at compile time. Either using std::include_str to get a string with the file content (and then parse at startup without needing the separate file) or you generate a valid rust file and use std::include and still get all the potential compiler optimizations from knowing the values of these constants.

But honestly, the const code for generating the values doesn't look thaaat bad. It's bad by rust standards, but not far from what equivalent C code would look like.

write rust syntax into that file and feed it into the build to delete misc fears about costs or failure modes of loading files