Hello good and helpful people,
For a personal learning project I am in a need of a long-lived
DashMap cache with string keys. I wondered: do I actually have to use the memory heap for the keys? Those keys will never change after all. So I settled for cloning a given
String because (a) the cache is going to live for the entirety of the program and (b) I can't find another way to reason with the borrow checker without using
Box et.al.: Rust Playground
I also tried using
the trait From<String> is not implemented for &str.
This is a personal learning project and I am trying to educate myself on what's the absolute most efficient way of having a long-lived map with immutable string keys, while using as little -- or no -- indirection (pointers) as possible.
Does my Rust Playground sample achieve this goal? Is the code idiomatic? Are there better ways?