I want to create a global hash map that maps strings to vectors of colors. This data needs to be queried by multiple functions and should just be hard coded into the program. That doesn’t seem possible.

Now, how is the right ™ way to do something like that in Rust? What if you need just a bunch of data structures from the beginning of the program until its end where some of the data needs to allocated?

You are viewing a single thread.
View all comments View context
4 points

lazy_static was the standard way as far as I’m concerned until this month. OnceCell or OnceLock should fill this role now.

permalink
report
parent
reply

Rust Programming

!rust@lemmy.ml

Create post

Community stats

  • 54

    Monthly active users

  • 239

    Posts

  • 718

    Comments