In rust libraries is it possible to initialize a variable at runtime at the start of execution. I'm looking to store some system properties as they are set at the applications start, before they have a chance to be changed.
By design, Rust does not provide a way to schedule initialization code to be executed before main(). But the lazy_static crate provides you with a way to initialize a global object on first access, which IIRC is how static local variables work in C++ and Java.
3 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.