about summary refs log tree commit diff
path: root/src/libstd/collections
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libstd/collections
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/libstd/collections')
-rw-r--r--src/libstd/collections/hash/map.rs92
-rw-r--r--src/libstd/collections/hash/set.rs224
2 files changed, 142 insertions, 174 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index de2f12c9f33..a928867d9de 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -487,9 +487,7 @@ where
     #[inline]
     #[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
     pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
-        HashMap {
-            base: base::HashMap::with_hasher(hash_builder),
-        }
+        HashMap { base: base::HashMap::with_hasher(hash_builder) }
     }
 
     /// Creates an empty `HashMap` with the specified capacity, using `hash_builder`
@@ -516,9 +514,7 @@ where
     #[inline]
     #[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
     pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {
-        HashMap {
-            base: base::HashMap::with_capacity_and_hasher(capacity, hash_builder),
-        }
+        HashMap { base: base::HashMap::with_capacity_and_hasher(capacity, hash_builder) }
     }
 
     /// Returns a reference to the map's [`BuildHasher`].
@@ -584,9 +580,7 @@ where
     #[inline]
     #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
     pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
-        self.base
-            .try_reserve(additional)
-            .map_err(map_collection_alloc_err)
+        self.base.try_reserve(additional).map_err(map_collection_alloc_err)
     }
 
     /// Shrinks the capacity of the map as much as possible. It will drop
@@ -636,10 +630,7 @@ where
     #[inline]
     #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
     pub fn shrink_to(&mut self, min_capacity: usize) {
-        assert!(
-            self.capacity() >= min_capacity,
-            "Tried to shrink to a larger capacity"
-        );
+        assert!(self.capacity() >= min_capacity, "Tried to shrink to a larger capacity");
         self.base.shrink_to(min_capacity);
     }
 
@@ -977,8 +968,7 @@ where
             return false;
         }
 
-        self.iter()
-            .all(|(key, value)| other.get(key).map_or(false, |v| *value == *v))
+        self.iter().all(|(key, value)| other.get(key).map_or(false, |v| *value == *v))
     }
 }
 
@@ -1053,9 +1043,7 @@ pub struct Iter<'a, K: 'a, V: 'a> {
 impl<K, V> Clone for Iter<'_, K, V> {
     #[inline]
     fn clone(&self) -> Self {
-        Iter {
-            base: self.base.clone(),
-        }
+        Iter { base: self.base.clone() }
     }
 }
 
@@ -1082,9 +1070,7 @@ impl<'a, K, V> IterMut<'a, K, V> {
     /// Returns a iterator of references over the remaining items.
     #[inline]
     pub(super) fn iter(&self) -> Iter<'_, K, V> {
-        Iter {
-            base: self.base.rustc_iter(),
-        }
+        Iter { base: self.base.rustc_iter() }
     }
 }
 
@@ -1104,9 +1090,7 @@ impl<K, V> IntoIter<K, V> {
     /// Returns a iterator of references over the remaining items.
     #[inline]
     pub(super) fn iter(&self) -> Iter<'_, K, V> {
-        Iter {
-            base: self.base.rustc_iter(),
-        }
+        Iter { base: self.base.rustc_iter() }
     }
 }
 
@@ -1127,9 +1111,7 @@ pub struct Keys<'a, K: 'a, V: 'a> {
 impl<K, V> Clone for Keys<'_, K, V> {
     #[inline]
     fn clone(&self) -> Self {
-        Keys {
-            inner: self.inner.clone(),
-        }
+        Keys { inner: self.inner.clone() }
     }
 }
 
@@ -1157,9 +1139,7 @@ pub struct Values<'a, K: 'a, V: 'a> {
 impl<K, V> Clone for Values<'_, K, V> {
     #[inline]
     fn clone(&self) -> Self {
-        Values {
-            inner: self.inner.clone(),
-        }
+        Values { inner: self.inner.clone() }
     }
 }
 
@@ -1186,9 +1166,7 @@ impl<'a, K, V> Drain<'a, K, V> {
     /// Returns a iterator of references over the remaining items.
     #[inline]
     pub(super) fn iter(&self) -> Iter<'_, K, V> {
-        Iter {
-            base: self.base.rustc_iter(),
-        }
+        Iter { base: self.base.rustc_iter() }
     }
 }
 
@@ -1285,12 +1263,7 @@ where
         K: Borrow<Q>,
         Q: Eq,
     {
-        map_raw_entry(
-            self.map
-                .base
-                .raw_entry_mut()
-                .from_key_hashed_nocheck(hash, k),
-        )
+        map_raw_entry(self.map.base.raw_entry_mut().from_key_hashed_nocheck(hash, k))
     }
 
     /// Creates a `RawEntryMut` from the given hash.
@@ -1650,10 +1623,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
 #[stable(feature = "debug_hash_map", since = "1.12.0")]
 impl<K: Debug, V: Debug> Debug for OccupiedEntry<'_, K, V> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_struct("OccupiedEntry")
-            .field("key", self.key())
-            .field("value", self.get())
-            .finish()
+        f.debug_struct("OccupiedEntry").field("key", self.key()).field("value", self.get()).finish()
     }
 }
 
@@ -1719,9 +1689,7 @@ impl<K, V, S> IntoIterator for HashMap<K, V, S> {
     /// ```
     #[inline]
     fn into_iter(self) -> IntoIter<K, V> {
-        IntoIter {
-            base: self.base.into_iter(),
-        }
+        IntoIter { base: self.base.into_iter() }
     }
 }
 
@@ -2051,7 +2019,7 @@ impl<'a, K, V> Entry<'a, K, V> {
             Occupied(mut entry) => {
                 entry.insert(value);
                 entry
-            },
+            }
             Vacant(entry) => entry.insert_entry(value),
         }
     }
@@ -2588,10 +2556,9 @@ fn map_entry<'a, K: 'a, V: 'a>(raw: base::RustcEntry<'a, K, V>) -> Entry<'a, K,
 fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> TryReserveError {
     match err {
         hashbrown::CollectionAllocErr::CapacityOverflow => TryReserveError::CapacityOverflow,
-        hashbrown::CollectionAllocErr::AllocErr { layout } => TryReserveError::AllocError {
-            layout,
-            non_exhaustive: (),
-        },
+        hashbrown::CollectionAllocErr::AllocErr { layout } => {
+            TryReserveError::AllocError { layout, non_exhaustive: () }
+        }
     }
 }
 
@@ -3323,7 +3290,7 @@ mod test_map {
     #[test]
     fn test_entry_take_doesnt_corrupt() {
         #![allow(deprecated)] //rand
-                              // Test for #19292
+        // Test for #19292
         fn check(m: &HashMap<i32, ()>) {
             for k in m.keys() {
                 assert!(m.contains_key(k), "{} is in keys() but not in the map?", k);
@@ -3483,14 +3450,8 @@ mod test_map {
         }
         let hash1 = compute_hash(&map, 1);
         assert_eq!(map.raw_entry().from_key(&1).unwrap(), (&1, &100));
-        assert_eq!(
-            map.raw_entry().from_hash(hash1, |k| *k == 1).unwrap(),
-            (&1, &100)
-        );
-        assert_eq!(
-            map.raw_entry().from_key_hashed_nocheck(hash1, &1).unwrap(),
-            (&1, &100)
-        );
+        assert_eq!(map.raw_entry().from_hash(hash1, |k| *k == 1).unwrap(), (&1, &100));
+        assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash1, &1).unwrap(), (&1, &100));
         assert_eq!(map.len(), 6);
 
         // Existing key (update)
@@ -3504,14 +3465,8 @@ mod test_map {
         }
         let hash2 = compute_hash(&map, 2);
         assert_eq!(map.raw_entry().from_key(&2).unwrap(), (&2, &200));
-        assert_eq!(
-            map.raw_entry().from_hash(hash2, |k| *k == 2).unwrap(),
-            (&2, &200)
-        );
-        assert_eq!(
-            map.raw_entry().from_key_hashed_nocheck(hash2, &2).unwrap(),
-            (&2, &200)
-        );
+        assert_eq!(map.raw_entry().from_hash(hash2, |k| *k == 2).unwrap(), (&2, &200));
+        assert_eq!(map.raw_entry().from_key_hashed_nocheck(hash2, &2).unwrap(), (&2, &200));
         assert_eq!(map.len(), 6);
 
         // Existing key (take)
@@ -3561,5 +3516,4 @@ mod test_map {
             }
         }
     }
-
 }
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index a038ee80210..fff64e9fc90 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -1,9 +1,9 @@
 use crate::borrow::Borrow;
 use crate::collections::TryReserveError;
 use crate::fmt;
-use crate::hash::{Hash, BuildHasher};
+use crate::hash::{BuildHasher, Hash};
 use crate::iter::{Chain, FromIterator, FusedIterator};
-use crate::ops::{BitOr, BitAnd, BitXor, Sub};
+use crate::ops::{BitAnd, BitOr, BitXor, Sub};
 
 use super::map::{self, HashMap, Keys, RandomState};
 
@@ -264,8 +264,9 @@ impl<T, S> HashSet<T, S> {
 }
 
 impl<T, S> HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     /// Creates a new empty hash set which will use the given hasher to hash
     /// keys.
@@ -380,7 +381,7 @@ impl<T, S> HashSet<T, S>
     /// set.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
     /// ```
     #[inline]
-    #[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
+    #[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
     pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
         self.map.try_reserve(additional)
     }
@@ -430,7 +431,7 @@ impl<T, S> HashSet<T, S>
     /// assert!(set.capacity() >= 2);
     /// ```
     #[inline]
-    #[unstable(feature = "shrink_to", reason = "new API", issue="56431")]
+    #[unstable(feature = "shrink_to", reason = "new API", issue = "56431")]
     pub fn shrink_to(&mut self, min_capacity: usize) {
         self.map.shrink_to(min_capacity)
     }
@@ -461,10 +462,7 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> {
-        Difference {
-            iter: self.iter(),
-            other,
-        }
+        Difference { iter: self.iter(), other }
     }
 
     /// Visits the values representing the symmetric difference,
@@ -490,9 +488,10 @@ impl<T, S> HashSet<T, S>
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn symmetric_difference<'a>(&'a self,
-                                    other: &'a HashSet<T, S>)
-                                    -> SymmetricDifference<'a, T, S> {
+    pub fn symmetric_difference<'a>(
+        &'a self,
+        other: &'a HashSet<T, S>,
+    ) -> SymmetricDifference<'a, T, S> {
         SymmetricDifference { iter: self.difference(other).chain(other.difference(self)) }
     }
 
@@ -518,15 +517,9 @@ impl<T, S> HashSet<T, S>
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
         if self.len() <= other.len() {
-            Intersection {
-                iter: self.iter(),
-                other,
-            }
+            Intersection { iter: self.iter(), other }
         } else {
-            Intersection {
-                iter: other.iter(),
-                other: self,
-            }
+            Intersection { iter: other.iter(), other: self }
         }
     }
 
@@ -552,13 +545,9 @@ impl<T, S> HashSet<T, S>
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
         if self.len() >= other.len() {
-            Union {
-                iter: self.iter().chain(other.difference(self)),
-            }
+            Union { iter: self.iter().chain(other.difference(self)) }
         } else {
-            Union {
-                iter: other.iter().chain(self.difference(other)),
-            }
+            Union { iter: other.iter().chain(self.difference(other)) }
         }
     }
 
@@ -583,8 +572,9 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
-        where T: Borrow<Q>,
-              Q: Hash + Eq
+    where
+        T: Borrow<Q>,
+        Q: Hash + Eq,
     {
         self.map.contains_key(value)
     }
@@ -610,8 +600,9 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[stable(feature = "set_recovery", since = "1.9.0")]
     pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
-        where T: Borrow<Q>,
-              Q: Hash + Eq
+    where
+        T: Borrow<Q>,
+        Q: Hash + Eq,
     {
         self.map.get_key_value(value).map(|(k, _)| k)
     }
@@ -663,9 +654,10 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[unstable(feature = "hash_set_entry", issue = "60896")]
     pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T
-        where T: Borrow<Q>,
-              Q: Hash + Eq,
-              F: FnOnce(&Q) -> T
+    where
+        T: Borrow<Q>,
+        Q: Hash + Eq,
+        F: FnOnce(&Q) -> T,
     {
         // Although the raw entry gives us `&mut T`, we only return `&T` to be consistent with
         // `get`. Key mutation is "raw" because you're not supposed to affect `Eq` or `Hash`.
@@ -717,11 +709,7 @@ impl<T, S> HashSet<T, S>
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn is_subset(&self, other: &HashSet<T, S>) -> bool {
-        if self.len() <= other.len() {
-            self.iter().all(|v| other.contains(v))
-        } else {
-            false
-        }
+        if self.len() <= other.len() { self.iter().all(|v| other.contains(v)) } else { false }
     }
 
     /// Returns `true` if the set is a superset of another,
@@ -824,8 +812,9 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
-        where T: Borrow<Q>,
-              Q: Hash + Eq
+    where
+        T: Borrow<Q>,
+        Q: Hash + Eq,
     {
         self.map.remove(value).is_some()
     }
@@ -851,8 +840,9 @@ impl<T, S> HashSet<T, S>
     #[inline]
     #[stable(feature = "set_recovery", since = "1.9.0")]
     pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
-        where T: Borrow<Q>,
-              Q: Hash + Eq
+    where
+        T: Borrow<Q>,
+        Q: Hash + Eq,
     {
         self.map.remove_entry(value).map(|(k, _)| k)
     }
@@ -873,7 +863,8 @@ impl<T, S> HashSet<T, S>
     /// ```
     #[stable(feature = "retain_hash_collection", since = "1.18.0")]
     pub fn retain<F>(&mut self, mut f: F)
-        where F: FnMut(&T) -> bool
+    where
+        F: FnMut(&T) -> bool,
     {
         self.map.retain(|k, _| f(k));
     }
@@ -881,8 +872,9 @@ impl<T, S> HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> PartialEq for HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     fn eq(&self, other: &HashSet<T, S>) -> bool {
         if self.len() != other.len() {
@@ -895,15 +887,17 @@ impl<T, S> PartialEq for HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> Eq for HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> fmt::Debug for HashSet<T, S>
-    where T: Eq + Hash + fmt::Debug,
-          S: BuildHasher
+where
+    T: Eq + Hash + fmt::Debug,
+    S: BuildHasher,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_set().entries(self.iter()).finish()
@@ -912,8 +906,9 @@ impl<T, S> fmt::Debug for HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> FromIterator<T> for HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash,
+    S: BuildHasher + Default,
 {
     #[inline]
     fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> HashSet<T, S> {
@@ -925,8 +920,9 @@ impl<T, S> FromIterator<T> for HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> Extend<T> for HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     #[inline]
     fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
@@ -936,8 +932,9 @@ impl<T, S> Extend<T> for HashSet<T, S>
 
 #[stable(feature = "hash_extend_copy", since = "1.4.0")]
 impl<'a, T, S> Extend<&'a T> for HashSet<T, S>
-    where T: 'a + Eq + Hash + Copy,
-          S: BuildHasher
+where
+    T: 'a + Eq + Hash + Copy,
+    S: BuildHasher,
 {
     #[inline]
     fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
@@ -947,8 +944,9 @@ impl<'a, T, S> Extend<&'a T> for HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> Default for HashSet<T, S>
-    where T: Eq + Hash,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash,
+    S: BuildHasher + Default,
 {
     /// Creates an empty `HashSet<T, S>` with the `Default` value for the hasher.
     #[inline]
@@ -959,8 +957,9 @@ impl<T, S> Default for HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> BitOr<&HashSet<T, S>> for &HashSet<T, S>
-    where T: Eq + Hash + Clone,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash + Clone,
+    S: BuildHasher + Default,
 {
     type Output = HashSet<T, S>;
 
@@ -991,8 +990,9 @@ impl<T, S> BitOr<&HashSet<T, S>> for &HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> BitAnd<&HashSet<T, S>> for &HashSet<T, S>
-    where T: Eq + Hash + Clone,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash + Clone,
+    S: BuildHasher + Default,
 {
     type Output = HashSet<T, S>;
 
@@ -1023,8 +1023,9 @@ impl<T, S> BitAnd<&HashSet<T, S>> for &HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> BitXor<&HashSet<T, S>> for &HashSet<T, S>
-    where T: Eq + Hash + Clone,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash + Clone,
+    S: BuildHasher + Default,
 {
     type Output = HashSet<T, S>;
 
@@ -1055,8 +1056,9 @@ impl<T, S> BitXor<&HashSet<T, S>> for &HashSet<T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T, S> Sub<&HashSet<T, S>> for &HashSet<T, S>
-    where T: Eq + Hash + Clone,
-          S: BuildHasher + Default
+where
+    T: Eq + Hash + Clone,
+    S: BuildHasher + Default,
 {
     type Output = HashSet<T, S>;
 
@@ -1280,9 +1282,7 @@ impl<K> FusedIterator for IntoIter<K> {}
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<K: fmt::Debug> fmt::Debug for IntoIter<K> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let entries_iter = self.iter
-            .iter()
-            .map(|(k, _)| k);
+        let entries_iter = self.iter.iter().map(|(k, _)| k);
         f.debug_list().entries(entries_iter).finish()
     }
 }
@@ -1313,9 +1313,7 @@ impl<K> FusedIterator for Drain<'_, K> {}
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<K: fmt::Debug> fmt::Debug for Drain<'_, K> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let entries_iter = self.iter
-            .iter()
-            .map(|(k, _)| k);
+        let entries_iter = self.iter.iter().map(|(k, _)| k);
         f.debug_list().entries(entries_iter).finish()
     }
 }
@@ -1330,8 +1328,9 @@ impl<T, S> Clone for Intersection<'_, T, S> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T, S> Iterator for Intersection<'a, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     type Item = &'a T;
 
@@ -1354,8 +1353,9 @@ impl<'a, T, S> Iterator for Intersection<'a, T, S>
 
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T, S> fmt::Debug for Intersection<'_, T, S>
-    where T: fmt::Debug + Eq + Hash,
-          S: BuildHasher
+where
+    T: fmt::Debug + Eq + Hash,
+    S: BuildHasher,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_list().entries(self.clone()).finish()
@@ -1364,8 +1364,9 @@ impl<T, S> fmt::Debug for Intersection<'_, T, S>
 
 #[stable(feature = "fused", since = "1.26.0")]
 impl<T, S> FusedIterator for Intersection<'_, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
 }
 
@@ -1379,8 +1380,9 @@ impl<T, S> Clone for Difference<'_, T, S> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T, S> Iterator for Difference<'a, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     type Item = &'a T;
 
@@ -1403,15 +1405,17 @@ impl<'a, T, S> Iterator for Difference<'a, T, S>
 
 #[stable(feature = "fused", since = "1.26.0")]
 impl<T, S> FusedIterator for Difference<'_, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
 }
 
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T, S> fmt::Debug for Difference<'_, T, S>
-    where T: fmt::Debug + Eq + Hash,
-          S: BuildHasher
+where
+    T: fmt::Debug + Eq + Hash,
+    S: BuildHasher,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_list().entries(self.clone()).finish()
@@ -1428,8 +1432,9 @@ impl<T, S> Clone for SymmetricDifference<'_, T, S> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     type Item = &'a T;
 
@@ -1445,15 +1450,17 @@ impl<'a, T, S> Iterator for SymmetricDifference<'a, T, S>
 
 #[stable(feature = "fused", since = "1.26.0")]
 impl<T, S> FusedIterator for SymmetricDifference<'_, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
 }
 
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T, S> fmt::Debug for SymmetricDifference<'_, T, S>
-    where T: fmt::Debug + Eq + Hash,
-          S: BuildHasher
+where
+    T: fmt::Debug + Eq + Hash,
+    S: BuildHasher,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_list().entries(self.clone()).finish()
@@ -1470,15 +1477,17 @@ impl<T, S> Clone for Union<'_, T, S> {
 
 #[stable(feature = "fused", since = "1.26.0")]
 impl<T, S> FusedIterator for Union<'_, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
 }
 
 #[stable(feature = "std_debug", since = "1.16.0")]
 impl<T, S> fmt::Debug for Union<'_, T, S>
-    where T: fmt::Debug + Eq + Hash,
-          S: BuildHasher
+where
+    T: fmt::Debug + Eq + Hash,
+    S: BuildHasher,
 {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_list().entries(self.clone()).finish()
@@ -1487,8 +1496,9 @@ impl<T, S> fmt::Debug for Union<'_, T, S>
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T, S> Iterator for Union<'a, T, S>
-    where T: Eq + Hash,
-          S: BuildHasher
+where
+    T: Eq + Hash,
+    S: BuildHasher,
 {
     type Item = &'a T;
 
@@ -1513,20 +1523,24 @@ fn assert_covariance() {
     fn into_iter<'new>(v: IntoIter<&'static str>) -> IntoIter<&'new str> {
         v
     }
-    fn difference<'a, 'new>(v: Difference<'a, &'static str, RandomState>)
-                            -> Difference<'a, &'new str, RandomState> {
+    fn difference<'a, 'new>(
+        v: Difference<'a, &'static str, RandomState>,
+    ) -> Difference<'a, &'new str, RandomState> {
         v
     }
-    fn symmetric_difference<'a, 'new>(v: SymmetricDifference<'a, &'static str, RandomState>)
-                                      -> SymmetricDifference<'a, &'new str, RandomState> {
+    fn symmetric_difference<'a, 'new>(
+        v: SymmetricDifference<'a, &'static str, RandomState>,
+    ) -> SymmetricDifference<'a, &'new str, RandomState> {
         v
     }
-    fn intersection<'a, 'new>(v: Intersection<'a, &'static str, RandomState>)
-                              -> Intersection<'a, &'new str, RandomState> {
+    fn intersection<'a, 'new>(
+        v: Intersection<'a, &'static str, RandomState>,
+    ) -> Intersection<'a, &'new str, RandomState> {
         v
     }
-    fn union<'a, 'new>(v: Union<'a, &'static str, RandomState>)
-                       -> Union<'a, &'new str, RandomState> {
+    fn union<'a, 'new>(
+        v: Union<'a, &'static str, RandomState>,
+    ) -> Union<'a, &'new str, RandomState> {
         v
     }
     fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
@@ -1536,8 +1550,8 @@ fn assert_covariance() {
 
 #[cfg(test)]
 mod test_set {
-    use super::HashSet;
     use super::super::map::RandomState;
+    use super::HashSet;
 
     #[test]
     fn test_zero_capacities() {