It's not because the data is held by a struct and I we can't prove that the struct has static lifetime. The data is iniited at startup and last for the life of the program.
Using OnceLock
was suggested here, but would require substantial refactoring.
Box::leak is another possibility and might have been better than what I did.
I do store Arc<Thing>
as the values in the HashMap. That's exactly what it is - the OP shows that.
But since an Arc's value can't change, I couldn't return an Arc<&Thing> without creating a new Arc. And you can't do that without cloning, so then I lose the advantage I was going for all along: not having to clone.
I should give more detail: The data is a map of dates to temporal data. A master cache holds the entire data set - years worth of data - and clients are typically after a few days at a time. So cloning on each get() is very wasteful.
And that's where the code is now, after a 3-hour refactoring to use Arc.
I will have to explore Box::leak, or using OnceLock after all...