Description
After rust-lang/rust@400c3a0d implemented RFC 509
HashMap::VacantEntry
now takes an additional type parameter Sized? Q: ToOwned<K>
The idea being that HashMap#entry()
now accepts the key by reference (&'a Q
instead of K
).
Then VacantEntry calls Q#to_owned() -> K
to store it in the map.
I've been trying to fix this; but I'm stumped. In TypeMap: the caller does not generate the TypeId, instead it is generated internally by TypeMap#entry()
.
Since no reference to this TypeId would live past the call to TypeMap#entry()
this invalidates the Entry<'a, K, V>
we're trying return.
The best I've been able to do so far is add a helper method that generates the TypeId and returns it to the caller so it lives long enough; then the caller passes it into TypeMap#entry()
... but it's a huge loss for ergonomics.