Skip to content

Commit

Permalink
table_seq: fix clippy warnings (needless lifetimes, unnecessary returns)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiju committed Oct 8, 2024
1 parent b7866fe commit c3c9978
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
38 changes: 19 additions & 19 deletions table_seq/src/map_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ pub struct MapSeqMap<'a, K, V, S> {
map: usize,
}

impl<'a, K, V, S> Clone for MapSeqMap<'a, K, V, S> {
impl<K, V, S> Clone for MapSeqMap<'_, K, V, S> {
fn clone(&self) -> Self {
*self
}
}

impl<'a, K, V, S> Copy for MapSeqMap<'a, K, V, S> {}
impl<K, V, S> Copy for MapSeqMap<'_, K, V, S> {}

impl<'a, K, V, S> std::ops::Deref for MapSeqMapMut<'a, K, V, S> {
type Target = MapSeqMap<'a, K, V, S>;
Expand All @@ -246,13 +246,13 @@ impl<'a, K, V, S> std::ops::Deref for MapSeqMapMut<'a, K, V, S> {
}
}

impl<'a, K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMap<'a, K, V, S> {
impl<K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMap<'_, K, V, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_set().entries(self.iter()).finish()
}
}

impl<'a, K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMapMut<'a, K, V, S> {
impl<K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for MapSeqMapMut<'_, K, V, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_set().entries(self.iter()).finish()
}
Expand Down Expand Up @@ -296,7 +296,7 @@ impl<'a, K, V, S> MapSeqMap<'a, K, V, S> {
}
}

impl<'a, K, V, S> MapSeqMapMut<'a, K, V, S> {
impl<K, V, S> MapSeqMapMut<'_, K, V, S> {
/// Discards all elements of the map.
#[inline(always)]
pub fn clear(&mut self) {
Expand All @@ -319,7 +319,7 @@ impl<'a, K, V, S> MapSeqMapMut<'a, K, V, S> {
}
}

impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMap<'a, K, V, S> {
impl<K: Eq + Hash, V, S: BuildHasher> MapSeqMap<'_, K, V, S> {
/// Returns `true` if the map contains an element for the given key.
#[inline(always)]
pub fn contains_key<Q>(&self, key: &Q) -> bool
Expand Down Expand Up @@ -353,7 +353,7 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMap<'a, K, V, S> {
}
}

impl<'a, K: Eq + Hash, V, S: BuildHasher> MapSeqMapMut<'a, K, V, S> {
impl<K: Eq + Hash, V, S: BuildHasher> MapSeqMapMut<'_, K, V, S> {
/// Returns a mutable reference to the value corresponding to the given key.
#[inline(always)]
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Expand Down Expand Up @@ -545,7 +545,7 @@ pub struct MapIter<'a, K, V> {
inner: SubtableIter<'a, MapEntry<K, V>>,
}

impl<'a, K, V> Default for MapIter<'a, K, V> {
impl<K, V> Default for MapIter<'_, K, V> {
#[inline(always)]
fn default() -> Self {
Self {
Expand All @@ -568,7 +568,7 @@ impl<'a, K, V> Iterator for MapIter<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for MapIter<'a, K, V> {
impl<K, V> ExactSizeIterator for MapIter<'_, K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
Expand All @@ -580,7 +580,7 @@ pub struct MapKeys<'a, K, V> {
inner: SubtableIter<'a, MapEntry<K, V>>,
}

impl<'a, K, V> Default for MapKeys<'a, K, V> {
impl<K, V> Default for MapKeys<'_, K, V> {
#[inline(always)]
fn default() -> Self {
Self {
Expand All @@ -603,7 +603,7 @@ impl<'a, K, V> Iterator for MapKeys<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for MapKeys<'a, K, V> {
impl<K, V> ExactSizeIterator for MapKeys<'_, K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
Expand All @@ -615,7 +615,7 @@ pub struct MapValues<'a, K, V> {
inner: SubtableIter<'a, MapEntry<K, V>>,
}

impl<'a, K, V> Default for MapValues<'a, K, V> {
impl<K, V> Default for MapValues<'_, K, V> {
#[inline(always)]
fn default() -> Self {
Self {
Expand All @@ -638,7 +638,7 @@ impl<'a, K, V> Iterator for MapValues<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for MapValues<'a, K, V> {
impl<K, V> ExactSizeIterator for MapValues<'_, K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
Expand All @@ -650,7 +650,7 @@ pub struct MapIterMut<'a, K, V> {
inner: SubtableIterMut<'a, MapEntry<K, V>>,
}

impl<'a, K, V> Default for MapIterMut<'a, K, V> {
impl<K, V> Default for MapIterMut<'_, K, V> {
#[inline(always)]
fn default() -> Self {
Self {
Expand All @@ -675,7 +675,7 @@ impl<'a, K, V> Iterator for MapIterMut<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for MapIterMut<'a, K, V> {
impl<K, V> ExactSizeIterator for MapIterMut<'_, K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
Expand All @@ -700,7 +700,7 @@ impl<'a, K, V, S> IntoIterator for MapSeqMapMut<'a, K, V, S> {
}
}

impl<'a, K, V, S> Extend<(K, V)> for MapSeqMapMut<'a, K, V, S>
impl<K, V, S> Extend<(K, V)> for MapSeqMapMut<'_, K, V, S>
where
K: Eq + Hash,
S: BuildHasher,
Expand All @@ -712,7 +712,7 @@ where
}
}

impl<'a, 'b, K, V, S> Extend<(&'b K, &'b V)> for MapSeqMapMut<'a, K, V, S>
impl<'b, K, V, S> Extend<(&'b K, &'b V)> for MapSeqMapMut<'_, K, V, S>
where
K: Eq + Hash + Copy,
V: Copy,
Expand All @@ -725,7 +725,7 @@ where
}
}

impl<'a, K, Q, V, S> std::ops::Index<&Q> for MapSeqMap<'a, K, V, S>
impl<K, Q, V, S> std::ops::Index<&Q> for MapSeqMap<'_, K, V, S>
where
K: Eq + Hash + Borrow<Q>,
S: BuildHasher,
Expand All @@ -738,7 +738,7 @@ where
}
}

impl<'a, K, Q, V, S> std::ops::Index<&Q> for MapSeqMapMut<'a, K, V, S>
impl<K, Q, V, S> std::ops::Index<&Q> for MapSeqMapMut<'_, K, V, S>
where
K: Eq + Hash + Borrow<Q>,
S: BuildHasher,
Expand Down
14 changes: 7 additions & 7 deletions table_seq/src/set_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct SetIter<'a, T> {
inner: SubtableIter<'a, T>,
}

impl<'a, T> Default for SetIter<'a, T> {
impl<T> Default for SetIter<'_, T> {
#[inline(always)]
fn default() -> Self {
Self {
Expand All @@ -36,7 +36,7 @@ impl<'a, T> Iterator for SetIter<'a, T> {
}
}

impl<'a, T> ExactSizeIterator for SetIter<'a, T> {
impl<T> ExactSizeIterator for SetIter<'_, T> {
#[inline(always)]
fn len(&self) -> usize {
self.inner.len()
Expand Down Expand Up @@ -273,13 +273,13 @@ impl<'a, T, S> std::ops::Deref for SetSeqSetMut<'a, T, S> {
}
}

impl<'a, T: fmt::Debug, S> fmt::Debug for SetSeqSet<'a, T, S> {
impl<T: fmt::Debug, S> fmt::Debug for SetSeqSet<'_, T, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_set().entries(self.iter()).finish()
}
}

impl<'a, T: fmt::Debug, S> fmt::Debug for SetSeqSetMut<'a, T, S> {
impl<T: fmt::Debug, S> fmt::Debug for SetSeqSetMut<'_, T, S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_set().entries(self.iter()).finish()
}
Expand Down Expand Up @@ -307,15 +307,15 @@ impl<'a, T, S> SetSeqSet<'a, T, S> {
}
}

impl<'a, T, S> SetSeqSetMut<'a, T, S> {
impl<T, S> SetSeqSetMut<'_, T, S> {
/// Discards all elements of the set.
#[inline(always)]
pub fn clear(&mut self) {
self.seq.clear_set(self.set)
}
}

impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSet<'a, T, S> {
impl<T: Eq + Hash, S: BuildHasher> SetSeqSet<'_, T, S> {
/// Checks whether a given value is an element of the set.
#[inline(always)]
pub fn contains<Q>(&self, value: &Q) -> bool
Expand All @@ -337,7 +337,7 @@ impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSet<'a, T, S> {
}
}

impl<'a, T: Eq + Hash, S: BuildHasher> SetSeqSetMut<'a, T, S> {
impl<T: Eq + Hash, S: BuildHasher> SetSeqSetMut<'_, T, S> {
/// Inserts a value into the set.
///
/// If the value is already present, the given value is discarded and the set is not modified.
Expand Down
6 changes: 3 additions & 3 deletions table_seq/src/table_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<T: fmt::Debug> fmt::Debug for TableSeq<T> {
#[derive(Clone)]
struct SubtableFmt<'a, T>(&'a TableSeq<T>, usize);

impl<'a, T: fmt::Debug> fmt::Debug for SubtableFmt<'a, T> {
impl<T: fmt::Debug> fmt::Debug for SubtableFmt<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_set().entries(self.0.subtable_iter(self.1)).finish()
}
Expand Down Expand Up @@ -96,7 +96,7 @@ const ALLOCATOR_SHIFT: u32 = 20;
/// Drop guard to prevent exposing invalid entries on panics.
struct InvalidateChunkOnDrop<'a, T>(&'a mut Chunk<T>);

impl<'a, T> Drop for InvalidateChunkOnDrop<'a, T> {
impl<T> Drop for InvalidateChunkOnDrop<'_, T> {
fn drop(&mut self) {
// This is only called when the drop implementation of an entry panics. In that situation,
// we do the minimum necessary to remain memory safe but spend no effort cleaning up. Since
Expand All @@ -111,7 +111,7 @@ impl<'a, T> Drop for InvalidateChunkOnDrop<'a, T> {
}
}

impl<'a, T> InvalidateChunkOnDrop<'a, T> {
impl<T> InvalidateChunkOnDrop<'_, T> {
fn defuse(self) {
let _ = ManuallyDrop::new(self);
}
Expand Down
4 changes: 2 additions & 2 deletions table_seq/src/table_seq/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ impl<T> TableSeq<T> {

match chunk.meta.entry_type(chunk_slot) {
EntryType::Empty => {
return Entry::Vacant(VacantEntry {
Entry::Vacant(VacantEntry {
tables: self,
subtable,
kind: VacantEntryKind::EmptyTable,
});
})
}
EntryType::Single => {
let node = chunk.node(chunk_alloc);
Expand Down
8 changes: 4 additions & 4 deletions table_seq/src/table_seq/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub struct SubtableIter<'a, T> {
inner: SubtableIterInner<'a, T>,
}

impl<'a, T> Default for SubtableIter<'a, T> {
impl<T> Default for SubtableIter<'_, T> {
fn default() -> Self {
Self {
inner: SubtableIterInner::Small([].as_slice().iter()),
Expand Down Expand Up @@ -62,7 +62,7 @@ impl<'a, T> Iterator for SubtableIter<'a, T> {
}
}

impl<'a, T> ExactSizeIterator for SubtableIter<'a, T> {
impl<T> ExactSizeIterator for SubtableIter<'_, T> {
fn len(&self) -> usize {
match &self.inner {
SubtableIterInner::Small(iter) => iter.len(),
Expand All @@ -76,7 +76,7 @@ pub struct SubtableIterMut<'a, T> {
inner: SubtableIterMutInner<'a, T>,
}

impl<'a, T> Default for SubtableIterMut<'a, T> {
impl<T> Default for SubtableIterMut<'_, T> {
fn default() -> Self {
Self {
inner: SubtableIterMutInner::Small(Default::default()),
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'a, T> Iterator for SubtableIterMut<'a, T> {
}
}

impl<'a, T> ExactSizeIterator for SubtableIterMut<'a, T> {
impl<T> ExactSizeIterator for SubtableIterMut<'_, T> {
fn len(&self) -> usize {
match &self.inner {
SubtableIterMutInner::Small(iter) => iter.len(),
Expand Down
6 changes: 3 additions & 3 deletions table_seq/src/table_seq/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ impl<T> SmallSubtable<T> {
}

if self.len() == SMALL_SUBTABLE_CAPACITY {
return SmallSubtableEntry::FullTable(self);
SmallSubtableEntry::FullTable(self)
} else {
return SmallSubtableEntry::Vacant(SmallSubtableVacantEntry {
SmallSubtableEntry::Vacant(SmallSubtableVacantEntry {
table: self,
byte_hash,
});
})
}
}

Expand Down

0 comments on commit c3c9978

Please sign in to comment.