You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
This appears to be a bug in the new Entry API, which requires the key reference to live as long as the map itself. This should be fixed upstream in the near future and there's unfortunately nothing we can really do about it for now.
After rust-lang/rust@400c3a0d implemented RFC 509
HashMap::VacantEntry
now takes an additional type parameterSized? Q: ToOwned<K>
The idea being that
HashMap#entry()
now accepts the key by reference (&'a Q
instead ofK
).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 theEntry<'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.The text was updated successfully, but these errors were encountered: