From 8edbf936d9c0e54e652a29e17152d6729c10aded Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 23 Jul 2020 14:17:49 -0700 Subject: [PATCH] style: use more anonymous lifetimes --- src/map.rs | 54 ++++++++++++++++++++++++------------------------ src/map/core.rs | 8 +++---- src/rayon/map.rs | 28 ++++++++++++------------- src/rayon/set.rs | 22 ++++++++++---------- src/set.rs | 52 +++++++++++++++++++++++----------------------- 5 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/map.rs b/src/map.rs index 4157c564..6025631e 100644 --- a/src/map.rs +++ b/src/map.rs @@ -733,28 +733,28 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> { iterator_methods!(Bucket::key_ref); } -impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> { - fn next_back(&mut self) -> Option<&'a K> { +impl DoubleEndedIterator for Keys<'_, K, V> { + fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::key_ref) } } -impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> { +impl ExactSizeIterator for Keys<'_, K, V> { fn len(&self) -> usize { self.iter.len() } } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -impl<'a, K, V> Clone for Keys<'a, K, V> { - fn clone(&self) -> Keys<'a, K, V> { +impl Clone for Keys<'_, K, V> { + fn clone(&self) -> Self { Keys { iter: self.iter.clone(), } } } -impl<'a, K: fmt::Debug, V> fmt::Debug for Keys<'a, K, V> { +impl fmt::Debug for Keys<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -777,28 +777,28 @@ impl<'a, K, V> Iterator for Values<'a, K, V> { iterator_methods!(Bucket::value_ref); } -impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> { +impl DoubleEndedIterator for Values<'_, K, V> { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::value_ref) } } -impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> { +impl ExactSizeIterator for Values<'_, K, V> { fn len(&self) -> usize { self.iter.len() } } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -impl<'a, K, V> Clone for Values<'a, K, V> { - fn clone(&self) -> Values<'a, K, V> { +impl Clone for Values<'_, K, V> { + fn clone(&self) -> Self { Values { iter: self.iter.clone(), } } } -impl<'a, K, V: fmt::Debug> fmt::Debug for Values<'a, K, V> { +impl fmt::Debug for Values<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -821,13 +821,13 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { iterator_methods!(Bucket::value_mut); } -impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> { +impl DoubleEndedIterator for ValuesMut<'_, K, V> { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::value_mut) } } -impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> { +impl ExactSizeIterator for ValuesMut<'_, K, V> { fn len(&self) -> usize { self.iter.len() } @@ -850,28 +850,28 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> { iterator_methods!(Bucket::refs); } -impl<'a, K, V> DoubleEndedIterator for Iter<'a, K, V> { +impl DoubleEndedIterator for Iter<'_, K, V> { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::refs) } } -impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> { +impl ExactSizeIterator for Iter<'_, K, V> { fn len(&self) -> usize { self.iter.len() } } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -impl<'a, K, V> Clone for Iter<'a, K, V> { - fn clone(&self) -> Iter<'a, K, V> { +impl Clone for Iter<'_, K, V> { + fn clone(&self) -> Self { Iter { iter: self.iter.clone(), } } } -impl<'a, K: fmt::Debug, V: fmt::Debug> fmt::Debug for Iter<'a, K, V> { +impl fmt::Debug for Iter<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -894,13 +894,13 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { iterator_methods!(Bucket::ref_mut); } -impl<'a, K, V> DoubleEndedIterator for IterMut<'a, K, V> { +impl DoubleEndedIterator for IterMut<'_, K, V> { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::ref_mut) } } -impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> { +impl ExactSizeIterator for IterMut<'_, K, V> { fn len(&self) -> usize { self.iter.len() } @@ -923,7 +923,7 @@ impl Iterator for IntoIter { iterator_methods!(Bucket::key_value); } -impl<'a, K, V> DoubleEndedIterator for IntoIter { +impl DoubleEndedIterator for IntoIter { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::key_value) } @@ -953,13 +953,13 @@ pub struct Drain<'a, K, V> { pub(crate) iter: vec::Drain<'a, Bucket>, } -impl<'a, K, V> Iterator for Drain<'a, K, V> { +impl Iterator for Drain<'_, K, V> { type Item = (K, V); iterator_methods!(Bucket::key_value); } -impl<'a, K, V> DoubleEndedIterator for Drain<'a, K, V> { +impl DoubleEndedIterator for Drain<'_, K, V> { double_ended_iterator_methods!(Bucket::key_value); } @@ -1001,7 +1001,7 @@ where } } -impl<'a, K, V, Q: ?Sized, S> Index<&'a Q> for IndexMap +impl Index<&Q> for IndexMap where Q: Hash + Equivalent, K: Hash + Eq, @@ -1010,7 +1010,7 @@ where type Output = V; /// ***Panics*** if `key` is not present in the map. - fn index(&self, key: &'a Q) -> &V { + fn index(&self, key: &Q) -> &V { self.get(key).expect("IndexMap: key not found") } } @@ -1019,14 +1019,14 @@ where /// pairs that are already present. /// /// You can **not** insert new pairs with index syntax, use `.insert()`. -impl<'a, K, V, Q: ?Sized, S> IndexMut<&'a Q> for IndexMap +impl IndexMut<&Q> for IndexMap where Q: Hash + Equivalent, K: Hash + Eq, S: BuildHasher, { /// ***Panics*** if `key` is not present in the map. - fn index_mut(&mut self, key: &'a Q) -> &mut V { + fn index_mut(&mut self, key: &Q) -> &mut V { self.get_mut(key).expect("IndexMap: key not found") } } diff --git a/src/map/core.rs b/src/map/core.rs index 044bae73..81f41125 100644 --- a/src/map/core.rs +++ b/src/map/core.rs @@ -296,7 +296,7 @@ impl<'a, K, V> Entry<'a, K, V> { } } -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Entry<'a, K, V> { +impl fmt::Debug for Entry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Entry::Vacant(ref v) => f.debug_tuple(stringify!(Entry)).field(v).finish(), @@ -308,7 +308,7 @@ impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for Entry<'a, K, V> pub use self::raw::OccupiedEntry; // Extra methods that don't threaten the unsafe encapsulation. -impl<'a, K, V> OccupiedEntry<'a, K, V> { +impl OccupiedEntry<'_, K, V> { /// Sets the value of the entry to `value`, and returns the entry's old value. pub fn insert(&mut self, value: V) -> V { replace(self.get_mut(), value) @@ -351,7 +351,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { } } -impl<'a, K: 'a + fmt::Debug, V: 'a + fmt::Debug> fmt::Debug for OccupiedEntry<'a, K, V> { +impl fmt::Debug for OccupiedEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct(stringify!(OccupiedEntry)) .field("key", self.key()) @@ -390,7 +390,7 @@ impl<'a, K, V> VacantEntry<'a, K, V> { } } -impl<'a, K: 'a + fmt::Debug, V: 'a> fmt::Debug for VacantEntry<'a, K, V> { +impl fmt::Debug for VacantEntry<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple(stringify!(VacantEntry)) .field(self.key()) diff --git a/src/rayon/map.rs b/src/rayon/map.rs index 417d2ee7..204c86dc 100644 --- a/src/rayon/map.rs +++ b/src/rayon/map.rs @@ -91,13 +91,13 @@ pub struct ParIter<'a, K, V> { entries: &'a [Bucket], } -impl<'a, K, V> Clone for ParIter<'a, K, V> { - fn clone(&self) -> ParIter<'a, K, V> { +impl Clone for ParIter<'_, K, V> { + fn clone(&self) -> Self { ParIter { ..*self } } } -impl<'a, K: fmt::Debug, V: fmt::Debug> fmt::Debug for ParIter<'a, K, V> { +impl fmt::Debug for ParIter<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let iter = self.entries.iter().map(Bucket::refs); f.debug_list().entries(iter).finish() @@ -110,7 +110,7 @@ impl<'a, K: Sync, V: Sync> ParallelIterator for ParIter<'a, K, V> { parallel_iterator_methods!(Bucket::refs); } -impl<'a, K: Sync, V: Sync> IndexedParallelIterator for ParIter<'a, K, V> { +impl IndexedParallelIterator for ParIter<'_, K, V> { indexed_parallel_iterator_methods!(Bucket::refs); } @@ -148,7 +148,7 @@ impl<'a, K: Sync + Send, V: Send> ParallelIterator for ParIterMut<'a, K, V> { parallel_iterator_methods!(Bucket::ref_mut); } -impl<'a, K: Sync + Send, V: Send> IndexedParallelIterator for ParIterMut<'a, K, V> { +impl IndexedParallelIterator for ParIterMut<'_, K, V> { indexed_parallel_iterator_methods!(Bucket::ref_mut); } @@ -209,13 +209,13 @@ pub struct ParKeys<'a, K, V> { entries: &'a [Bucket], } -impl<'a, K, V> Clone for ParKeys<'a, K, V> { - fn clone(&self) -> ParKeys<'a, K, V> { +impl Clone for ParKeys<'_, K, V> { + fn clone(&self) -> Self { ParKeys { ..*self } } } -impl<'a, K: fmt::Debug, V> fmt::Debug for ParKeys<'a, K, V> { +impl fmt::Debug for ParKeys<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let iter = self.entries.iter().map(Bucket::key_ref); f.debug_list().entries(iter).finish() @@ -228,7 +228,7 @@ impl<'a, K: Sync, V: Sync> ParallelIterator for ParKeys<'a, K, V> { parallel_iterator_methods!(Bucket::key_ref); } -impl<'a, K: Sync, V: Sync> IndexedParallelIterator for ParKeys<'a, K, V> { +impl IndexedParallelIterator for ParKeys<'_, K, V> { indexed_parallel_iterator_methods!(Bucket::key_ref); } @@ -243,13 +243,13 @@ pub struct ParValues<'a, K, V> { entries: &'a [Bucket], } -impl<'a, K, V> Clone for ParValues<'a, K, V> { - fn clone(&self) -> ParValues<'a, K, V> { +impl Clone for ParValues<'_, K, V> { + fn clone(&self) -> Self { ParValues { ..*self } } } -impl<'a, K, V: fmt::Debug> fmt::Debug for ParValues<'a, K, V> { +impl fmt::Debug for ParValues<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let iter = self.entries.iter().map(Bucket::value_ref); f.debug_list().entries(iter).finish() @@ -262,7 +262,7 @@ impl<'a, K: Sync, V: Sync> ParallelIterator for ParValues<'a, K, V> { parallel_iterator_methods!(Bucket::value_ref); } -impl<'a, K: Sync, V: Sync> IndexedParallelIterator for ParValues<'a, K, V> { +impl IndexedParallelIterator for ParValues<'_, K, V> { indexed_parallel_iterator_methods!(Bucket::value_ref); } @@ -336,7 +336,7 @@ impl<'a, K: Send, V: Send> ParallelIterator for ParValuesMut<'a, K, V> { parallel_iterator_methods!(Bucket::value_mut); } -impl<'a, K: Send, V: Send> IndexedParallelIterator for ParValuesMut<'a, K, V> { +impl IndexedParallelIterator for ParValuesMut<'_, K, V> { indexed_parallel_iterator_methods!(Bucket::value_mut); } diff --git a/src/rayon/set.rs b/src/rayon/set.rs index af316bb5..49b8792f 100644 --- a/src/rayon/set.rs +++ b/src/rayon/set.rs @@ -90,13 +90,13 @@ pub struct ParIter<'a, T> { entries: &'a [Bucket], } -impl<'a, T> Clone for ParIter<'a, T> { +impl Clone for ParIter<'_, T> { fn clone(&self) -> Self { ParIter { ..*self } } } -impl<'a, T: fmt::Debug> fmt::Debug for ParIter<'a, T> { +impl fmt::Debug for ParIter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let iter = self.entries.iter().map(Bucket::key_ref); f.debug_list().entries(iter).finish() @@ -109,7 +109,7 @@ impl<'a, T: Sync> ParallelIterator for ParIter<'a, T> { parallel_iterator_methods!(Bucket::key_ref); } -impl<'a, T: Sync> IndexedParallelIterator for ParIter<'a, T> { +impl IndexedParallelIterator for ParIter<'_, T> { indexed_parallel_iterator_methods!(Bucket::key_ref); } @@ -246,13 +246,13 @@ pub struct ParDifference<'a, T, S1, S2> { set2: &'a IndexSet, } -impl<'a, T, S1, S2> Clone for ParDifference<'a, T, S1, S2> { +impl Clone for ParDifference<'_, T, S1, S2> { fn clone(&self) -> Self { ParDifference { ..*self } } } -impl<'a, T, S1, S2> fmt::Debug for ParDifference<'a, T, S1, S2> +impl fmt::Debug for ParDifference<'_, T, S1, S2> where T: fmt::Debug + Eq + Hash, S1: BuildHasher, @@ -297,13 +297,13 @@ pub struct ParIntersection<'a, T, S1, S2> { set2: &'a IndexSet, } -impl<'a, T, S1, S2> Clone for ParIntersection<'a, T, S1, S2> { +impl Clone for ParIntersection<'_, T, S1, S2> { fn clone(&self) -> Self { ParIntersection { ..*self } } } -impl<'a, T, S1, S2> fmt::Debug for ParIntersection<'a, T, S1, S2> +impl fmt::Debug for ParIntersection<'_, T, S1, S2> where T: fmt::Debug + Eq + Hash, S1: BuildHasher, @@ -348,13 +348,13 @@ pub struct ParSymmetricDifference<'a, T, S1, S2> { set2: &'a IndexSet, } -impl<'a, T, S1, S2> Clone for ParSymmetricDifference<'a, T, S1, S2> { +impl Clone for ParSymmetricDifference<'_, T, S1, S2> { fn clone(&self) -> Self { ParSymmetricDifference { ..*self } } } -impl<'a, T, S1, S2> fmt::Debug for ParSymmetricDifference<'a, T, S1, S2> +impl fmt::Debug for ParSymmetricDifference<'_, T, S1, S2> where T: fmt::Debug + Eq + Hash, S1: BuildHasher, @@ -399,13 +399,13 @@ pub struct ParUnion<'a, T, S1, S2> { set2: &'a IndexSet, } -impl<'a, T, S1, S2> Clone for ParUnion<'a, T, S1, S2> { +impl Clone for ParUnion<'_, T, S1, S2> { fn clone(&self) -> Self { ParUnion { ..*self } } } -impl<'a, T, S1, S2> fmt::Debug for ParUnion<'a, T, S1, S2> +impl fmt::Debug for ParUnion<'_, T, S1, S2> where T: fmt::Debug + Eq + Hash, S1: BuildHasher, diff --git a/src/set.rs b/src/set.rs index fdd9e67d..c1693c54 100644 --- a/src/set.rs +++ b/src/set.rs @@ -655,19 +655,19 @@ impl<'a, T> Iterator for Iter<'a, T> { iterator_methods!(Bucket::key_ref); } -impl<'a, T> DoubleEndedIterator for Iter<'a, T> { +impl DoubleEndedIterator for Iter<'_, T> { fn next_back(&mut self) -> Option { self.iter.next_back().map(Bucket::key_ref) } } -impl<'a, T> ExactSizeIterator for Iter<'a, T> { +impl ExactSizeIterator for Iter<'_, T> { fn len(&self) -> usize { self.iter.len() } } -impl<'a, T> Clone for Iter<'a, T> { +impl Clone for Iter<'_, T> { fn clone(&self) -> Self { Iter { iter: self.iter.clone(), @@ -675,7 +675,7 @@ impl<'a, T> Clone for Iter<'a, T> { } } -impl<'a, T: fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.clone()).finish() } @@ -692,13 +692,13 @@ pub struct Drain<'a, T> { iter: vec::Drain<'a, Bucket>, } -impl<'a, T> Iterator for Drain<'a, T> { +impl Iterator for Drain<'_, T> { type Item = T; iterator_methods!(Bucket::key); } -impl<'a, T> DoubleEndedIterator for Drain<'a, T> { +impl DoubleEndedIterator for Drain<'_, T> { double_ended_iterator_methods!(Bucket::key); } @@ -862,7 +862,7 @@ where } } -impl<'a, T, S> DoubleEndedIterator for Difference<'a, T, S> +impl DoubleEndedIterator for Difference<'_, T, S> where T: Eq + Hash, S: BuildHasher, @@ -877,7 +877,7 @@ where } } -impl<'a, T, S> Clone for Difference<'a, T, S> { +impl Clone for Difference<'_, T, S> { fn clone(&self) -> Self { Difference { iter: self.iter.clone(), @@ -886,7 +886,7 @@ impl<'a, T, S> Clone for Difference<'a, T, S> { } } -impl<'a, T, S> fmt::Debug for Difference<'a, T, S> +impl fmt::Debug for Difference<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher, @@ -929,7 +929,7 @@ where } } -impl<'a, T, S> DoubleEndedIterator for Intersection<'a, T, S> +impl DoubleEndedIterator for Intersection<'_, T, S> where T: Eq + Hash, S: BuildHasher, @@ -944,7 +944,7 @@ where } } -impl<'a, T, S> Clone for Intersection<'a, T, S> { +impl Clone for Intersection<'_, T, S> { fn clone(&self) -> Self { Intersection { iter: self.iter.clone(), @@ -953,7 +953,7 @@ impl<'a, T, S> Clone for Intersection<'a, T, S> { } } -impl<'a, T, S> fmt::Debug for Intersection<'a, T, S> +impl fmt::Debug for Intersection<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher, @@ -998,7 +998,7 @@ where } } -impl<'a, T, S1, S2> DoubleEndedIterator for SymmetricDifference<'a, T, S1, S2> +impl DoubleEndedIterator for SymmetricDifference<'_, T, S1, S2> where T: Eq + Hash, S1: BuildHasher, @@ -1009,7 +1009,7 @@ where } } -impl<'a, T, S1, S2> Clone for SymmetricDifference<'a, T, S1, S2> { +impl Clone for SymmetricDifference<'_, T, S1, S2> { fn clone(&self) -> Self { SymmetricDifference { iter: self.iter.clone(), @@ -1017,7 +1017,7 @@ impl<'a, T, S1, S2> Clone for SymmetricDifference<'a, T, S1, S2> { } } -impl<'a, T, S1, S2> fmt::Debug for SymmetricDifference<'a, T, S1, S2> +impl fmt::Debug for SymmetricDifference<'_, T, S1, S2> where T: fmt::Debug + Eq + Hash, S1: BuildHasher, @@ -1062,7 +1062,7 @@ where } } -impl<'a, T, S> DoubleEndedIterator for Union<'a, T, S> +impl DoubleEndedIterator for Union<'_, T, S> where T: Eq + Hash, S: BuildHasher, @@ -1072,7 +1072,7 @@ where } } -impl<'a, T, S> Clone for Union<'a, T, S> { +impl Clone for Union<'_, T, S> { fn clone(&self) -> Self { Union { iter: self.iter.clone(), @@ -1080,7 +1080,7 @@ impl<'a, T, S> Clone for Union<'a, T, S> { } } -impl<'a, T, S> fmt::Debug for Union<'a, T, S> +impl fmt::Debug for Union<'_, T, S> where T: fmt::Debug + Eq + Hash, S: BuildHasher, @@ -1090,7 +1090,7 @@ where } } -impl<'a, 'b, T, S1, S2> BitAnd<&'b IndexSet> for &'a IndexSet +impl BitAnd<&IndexSet> for &IndexSet where T: Eq + Hash + Clone, S1: BuildHasher + Default, @@ -1101,12 +1101,12 @@ where /// Returns the set intersection, cloned into a new set. /// /// Values are collected in the same order that they appear in `self`. - fn bitand(self, other: &'b IndexSet) -> Self::Output { + fn bitand(self, other: &IndexSet) -> Self::Output { self.intersection(other).cloned().collect() } } -impl<'a, 'b, T, S1, S2> BitOr<&'b IndexSet> for &'a IndexSet +impl BitOr<&IndexSet> for &IndexSet where T: Eq + Hash + Clone, S1: BuildHasher + Default, @@ -1118,12 +1118,12 @@ where /// /// Values from `self` are collected in their original order, followed by /// values that are unique to `other` in their original order. - fn bitor(self, other: &'b IndexSet) -> Self::Output { + fn bitor(self, other: &IndexSet) -> Self::Output { self.union(other).cloned().collect() } } -impl<'a, 'b, T, S1, S2> BitXor<&'b IndexSet> for &'a IndexSet +impl BitXor<&IndexSet> for &IndexSet where T: Eq + Hash + Clone, S1: BuildHasher + Default, @@ -1135,12 +1135,12 @@ where /// /// Values from `self` are collected in their original order, followed by /// values from `other` in their original order. - fn bitxor(self, other: &'b IndexSet) -> Self::Output { + fn bitxor(self, other: &IndexSet) -> Self::Output { self.symmetric_difference(other).cloned().collect() } } -impl<'a, 'b, T, S1, S2> Sub<&'b IndexSet> for &'a IndexSet +impl Sub<&IndexSet> for &IndexSet where T: Eq + Hash + Clone, S1: BuildHasher + Default, @@ -1151,7 +1151,7 @@ where /// Returns the set difference, cloned into a new set. /// /// Values are collected in the same order that they appear in `self`. - fn sub(self, other: &'b IndexSet) -> Self::Output { + fn sub(self, other: &IndexSet) -> Self::Output { self.difference(other).cloned().collect() } }