Unnecessary trait bounds in HashMap (and BTreeMap) #44777
Labels
C-feature-accepted
Category: A feature request that has been accepted pending implementation.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
There's a lot of unnecessary trait bounds in
HashMap
that could be pruned.Examples:
impl Default for HashMap<K, V, S>
really only needsS: Default
impl Debug for HashMap<K, V, S>
really only needsK: Debug
andV: Debug
K: Eq + Hash
orS: BuildHasher
, or sometimes neither.Most of this isn't a big deal, but for
Default
andDebug
this 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
Default
or.len()
, no sensible implementation should ever useK: Eq + Hash
at all.This also applies to
BTreeMap
to some extent (Default
doesn't needOrd
, for example).Patch: Rufflewind@a1587a1
The text was updated successfully, but these errors were encountered: