Skip to content

Commit

Permalink
Merge pull request #140 from cuviper/'_
Browse files Browse the repository at this point in the history
style: use more anonymous lifetimes
  • Loading branch information
cuviper authored Jul 23, 2020
2 parents 041ee54 + 8edbf93 commit 4f10104
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 82 deletions.
54 changes: 27 additions & 27 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K, V> DoubleEndedIterator for Keys<'_, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::key_ref)
}
}

impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
impl<K, V> 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<K, V> 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<K: fmt::Debug, V> fmt::Debug for Keys<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand All @@ -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<K, V> DoubleEndedIterator for Values<'_, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::value_ref)
}
}

impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
impl<K, V> 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<K, V> 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<K, V: fmt::Debug> fmt::Debug for Values<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand All @@ -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<K, V> DoubleEndedIterator for ValuesMut<'_, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::value_mut)
}
}

impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
impl<K, V> ExactSizeIterator for ValuesMut<'_, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
Expand All @@ -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<K, V> DoubleEndedIterator for Iter<'_, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::refs)
}
}

impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
impl<K, V> 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<K, V> 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<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Iter<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
Expand All @@ -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<K, V> DoubleEndedIterator for IterMut<'_, K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::ref_mut)
}
}

impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {
impl<K, V> ExactSizeIterator for IterMut<'_, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
Expand All @@ -923,7 +923,7 @@ impl<K, V> Iterator for IntoIter<K, V> {
iterator_methods!(Bucket::key_value);
}

impl<'a, K, V> DoubleEndedIterator for IntoIter<K, V> {
impl<K, V> DoubleEndedIterator for IntoIter<K, V> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(Bucket::key_value)
}
Expand Down Expand Up @@ -953,13 +953,13 @@ pub struct Drain<'a, K, V> {
pub(crate) iter: vec::Drain<'a, Bucket<K, V>>,
}

impl<'a, K, V> Iterator for Drain<'a, K, V> {
impl<K, V> 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<K, V> DoubleEndedIterator for Drain<'_, K, V> {
double_ended_iterator_methods!(Bucket::key_value);
}

Expand Down Expand Up @@ -1001,7 +1001,7 @@ where
}
}

impl<'a, K, V, Q: ?Sized, S> Index<&'a Q> for IndexMap<K, V, S>
impl<K, V, Q: ?Sized, S> Index<&Q> for IndexMap<K, V, S>
where
Q: Hash + Equivalent<K>,
K: Hash + Eq,
Expand All @@ -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")
}
}
Expand All @@ -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<K, V, S>
impl<K, V, Q: ?Sized, S> IndexMut<&Q> for IndexMap<K, V, S>
where
Q: Hash + Equivalent<K>,
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")
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/map/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<K: fmt::Debug, V: fmt::Debug> 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(),
Expand All @@ -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<K, V> 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)
Expand Down Expand Up @@ -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<K: fmt::Debug, V: fmt::Debug> fmt::Debug for OccupiedEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct(stringify!(OccupiedEntry))
.field("key", self.key())
Expand Down Expand Up @@ -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<K: fmt::Debug, V> fmt::Debug for VacantEntry<'_, K, V> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple(stringify!(VacantEntry))
.field(self.key())
Expand Down
28 changes: 14 additions & 14 deletions src/rayon/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ pub struct ParIter<'a, K, V> {
entries: &'a [Bucket<K, V>],
}

impl<'a, K, V> Clone for ParIter<'a, K, V> {
fn clone(&self) -> ParIter<'a, K, V> {
impl<K, V> 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<K: fmt::Debug, V: fmt::Debug> 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()
Expand All @@ -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<K: Sync, V: Sync> IndexedParallelIterator for ParIter<'_, K, V> {
indexed_parallel_iterator_methods!(Bucket::refs);
}

Expand Down Expand Up @@ -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<K: Sync + Send, V: Send> IndexedParallelIterator for ParIterMut<'_, K, V> {
indexed_parallel_iterator_methods!(Bucket::ref_mut);
}

Expand Down Expand Up @@ -209,13 +209,13 @@ pub struct ParKeys<'a, K, V> {
entries: &'a [Bucket<K, V>],
}

impl<'a, K, V> Clone for ParKeys<'a, K, V> {
fn clone(&self) -> ParKeys<'a, K, V> {
impl<K, V> 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<K: fmt::Debug, V> 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()
Expand All @@ -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<K: Sync, V: Sync> IndexedParallelIterator for ParKeys<'_, K, V> {
indexed_parallel_iterator_methods!(Bucket::key_ref);
}

Expand All @@ -243,13 +243,13 @@ pub struct ParValues<'a, K, V> {
entries: &'a [Bucket<K, V>],
}

impl<'a, K, V> Clone for ParValues<'a, K, V> {
fn clone(&self) -> ParValues<'a, K, V> {
impl<K, V> 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<K, V: fmt::Debug> 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()
Expand All @@ -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<K: Sync, V: Sync> IndexedParallelIterator for ParValues<'_, K, V> {
indexed_parallel_iterator_methods!(Bucket::value_ref);
}

Expand Down Expand Up @@ -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<K: Send, V: Send> IndexedParallelIterator for ParValuesMut<'_, K, V> {
indexed_parallel_iterator_methods!(Bucket::value_mut);
}

Expand Down
Loading

0 comments on commit 4f10104

Please sign in to comment.