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
Relax constraint in hash_map::EntryRef insertion methods K: From<&Q> to &Q: Into<K>
Currently `EntryRef::or_insert*` methods have constraint `K: From<&Q>` which is
required to construct "owned" key from "borrowed" key during insertion operation.
Rust documentation recommends not to use `From` as trait constraint, and instead
prefer to use reversed `Into` trait constraint:
https://doc.rust-lang.org/std/convert/trait.From.html
> Prefer using Into over using From when specifying trait bounds on a generic
> function. This way, types that directly implement Into can be used as arguments as well.
Changing constraint `K: From<&Q>` to `&Q: Into<K>` extends support of insert operation
to additional cases where `K` does not implement trait `From<&Q>`, but `&Q` does implement
trait `Into<K>`.
**API compatibility**: `&Q: Into<K>` is a strict superset of `K: From<&Q>` (because of blanket
implementation https://doc.rust-lang.org/std/convert/trait.Into.html#impl-Into%3CU%3E-for-T),
so this change does not break existing hashbrown API compatibility; all existing code will work
with new trait constraints.
0 commit comments