-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Unnecessary trait bounds in HashMap (and BTreeMap) #44777
Copy link
Copy link
Closed
Labels
C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
There's a lot of unnecessary trait bounds in
HashMapthat could be pruned.Examples:
impl Default for HashMap<K, V, S>really only needsS: Defaultimpl Debug for HashMap<K, V, S>really only needsK: DebugandV: DebugK: Eq + HashorS: BuildHasher, or sometimes neither.Most of this isn't a big deal, but for
DefaultandDebugthis is a nuisance because you can't use#[derive(Debug, Default)]on unconstrained types containingHashMap, e.g.One might argue that this would limit potential implementations, but for a lot them like
Defaultor.len(), no sensible implementation should ever useK: Eq + Hashat all.This also applies to
BTreeMapto some extent (Defaultdoesn't needOrd, for example).Patch: Rufflewind@a1587a1