about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-26 14:12:56 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-26 19:24:45 -0500
commit48859db151b839518bdd9d44a2387c0f6b65d141 (patch)
treeb6baa53fb9e0d98b3b5362e6749364483ed98701 /src/libstd
parent3b92689f3d0c3b90fa01d9873cdf01543d51c000 (diff)
downloadrust-48859db151b839518bdd9d44a2387c0f6b65d141.tar.gz
rust-48859db151b839518bdd9d44a2387c0f6b65d141.zip
Relax bounds on HashSet to match hashbrown
No functional changes are made, and all APIs are moved to strictly less
restrictive bounds.

These APIs changed from the old bound listed to the new bound:

T: Hash + Eq -> T
* new
* with_capacity

T: Eq + Hash, S: BuildHasher -> T
* with_hasher
* with_capacity_and_hasher
* hasher

T: Eq + Hash + Debug -> T: Debug
S: BuildHasher -> S
<HashSet as Debug>

T: Eq + Hash -> T
S: BuildHasher + Default -> S: Default
<HashSet as Default>
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/set.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index fff64e9fc90..f461f26572f 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -110,7 +110,7 @@ pub struct HashSet<T, S = RandomState> {
     map: HashMap<T, (), S>,
 }
 
-impl<T: Hash + Eq> HashSet<T, RandomState> {
+impl<T> HashSet<T, RandomState> {
     /// Creates an empty `HashSet`.
     ///
     /// The hash set is initially created with a capacity of 0, so it will not allocate until it
@@ -261,13 +261,7 @@ impl<T, S> HashSet<T, S> {
     pub fn clear(&mut self) {
         self.map.clear()
     }
-}
 
-impl<T, S> HashSet<T, S>
-where
-    T: Eq + Hash,
-    S: BuildHasher,
-{
     /// Creates a new empty hash set which will use the given hasher to hash
     /// keys.
     ///
@@ -340,7 +334,13 @@ where
     pub fn hasher(&self) -> &S {
         self.map.hasher()
     }
+}
 
+impl<T, S> HashSet<T, S>
+where
+    T: Eq + Hash,
+    S: BuildHasher,
+{
     /// Reserves capacity for at least `additional` more elements to be inserted
     /// in the `HashSet`. The collection may reserve more space to avoid
     /// frequent reallocations.
@@ -896,8 +896,7 @@ where
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> fmt::Debug for HashSet<T, S>
 where
-    T: Eq + Hash + fmt::Debug,
-    S: BuildHasher,
+    T: fmt::Debug,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_set().entries(self.iter()).finish()
@@ -945,8 +944,7 @@ where
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> Default for HashSet<T, S>
 where
-    T: Eq + Hash,
-    S: BuildHasher + Default,
+    S: Default,
 {
     /// Creates an empty `HashSet<T, S>` with the `Default` value for the hasher.
     #[inline]