Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lifetimes of iterators #121

Merged
merged 1 commit into from
Dec 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
}

/// An iterator visiting all entries in most-recently used order. The iterator element type is
/// `(&'a K, &'a V)`.
/// `(&K, &V)`.
///
/// # Examples
///
Expand All @@ -700,7 +700,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// println!("key: {} val: {}", key, val);
/// }
/// ```
pub fn iter<'a>(&'_ self) -> Iter<'a, K, V> {
pub fn iter(&self) -> Iter<'_, K, V> {
Iter {
len: self.len(),
ptr: unsafe { (*self.head).next },
Expand All @@ -710,7 +710,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
}

/// An iterator visiting all entries in most-recently-used order, giving a mutable reference on
/// V. The iterator element type is `(&'a K, &'a mut V)`.
/// V. The iterator element type is `(&K, &mut V)`.
///
/// # Examples
///
Expand All @@ -735,7 +735,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// }
/// }
/// ```
pub fn iter_mut<'a>(&'_ mut self) -> IterMut<'a, K, V> {
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
IterMut {
len: self.len(),
ptr: unsafe { (*self.head).next },
Expand Down