logoalt Hacker News

Animatstoday at 1:18 AM1 replyview on HN

Yes. There isn't Rust language support for this.

Order of initialization can be supported at various levels:

- Completely random (OK if interdependence are locked out, otherwise bad)

- Consistent, but sorted by something such as alphabetical name (meh.)

- Manual, controlled in linker scripts (headache)

- True dependency tree order, including diagnosing loops (seen in the Modula family).

General comment: yes, you can, and you probably shouldn't unless you have profiling data that indicates a significant performance improvement for a critical use case.


Replies

ameliaquiningtoday at 2:09 AM

I think these things are used more for developer experience than for performance, since you can always just do the initialization in main if you really have to.

show 1 reply