hashbrown
hashbrown copied to clipboard
Lifetime of input (key) to HashMap::get() gets entanged w/ that of its output (value)
This issue I filed against std also applies to hashbrown::HashMap. You can use the exact same code in there, replacing the HashMap use line and reproduce the issue. The problem is likely that lifetimes are not specified for HashMap::get arguments so rustc thinks the passed key's lifetime is somehow associated with that of self.
If that's the correct diagnoses, I'll hopefully provide a PR for both hashbrown and std soon.
This feels like a compiler bug to me: the get function definition should return a value with the same lifetime as &self.
This feels like a compiler bug to me: the
getfunction definition should return a value with the same lifetime as&self.
It's very much possible. I did a bit of research but no matter what lifetimes I assign to all the functions in the chain, it doesn't help. :shrug: