I have a set of data structures over a set of static lookup data that I'm intentionally leaking using
Box::leak(). Thus the type of the data structure is:
HashMap<MyKeyType, &'static LookupData>
Iterating over this structure is a little awkward, because the iterator gives a
&T, so code like this fails to compile:
let filtered_things: Vec<&'static LookupData> = mymap.values().filter(...).collect();
This fails with a message "a collection of type std::vec::Vec<&LookupData> cannot be built from std::iter::Iterator<Item=&&LookupData>"
I can solve this by hand by adding an extra .map(|data| data) which coerces the && into a single ref... but is there a better pattern or way of doing this?