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

Remove needless lifetimes (clippy warnings) #196

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// assert_eq!(cache.get_or_insert(1, ||"a"), &"a");
/// assert_eq!(cache.get_or_insert(1, ||"b"), &"a");
/// ```
pub fn get_or_insert<'a, F>(&'a mut self, k: K, f: F) -> &'a V
pub fn get_or_insert<F>(&mut self, k: K, f: F) -> &V
where
F: FnOnce() -> V,
{
Expand Down Expand Up @@ -641,7 +641,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// assert_eq!(cache.get_or_insert_mut(3, ||"f"), &mut "f");
/// assert_eq!(cache.get_or_insert_mut(3, ||"e"), &mut "f");
/// ```
pub fn get_or_insert_mut<'a, F>(&'a mut self, k: K, f: F) -> &'a mut V
pub fn get_or_insert_mut<F>(&mut self, k: K, f: F) -> &mut V
where
F: FnOnce() -> V,
{
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// assert_eq!(cache.try_get_or_insert_mut(4, b), Ok(&mut "b"));
/// assert_eq!(cache.try_get_or_insert_mut(4, a), Ok(&mut "b"));
/// ```
pub fn try_get_or_insert_mut<'a, F, E>(&'a mut self, k: K, f: F) -> Result<&'a mut V, E>
pub fn try_get_or_insert_mut<F, E>(&mut self, k: K, f: F) -> Result<&mut V, E>
where
F: FnOnce() -> Result<V, E>,
{
Expand Down Expand Up @@ -788,7 +788,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
///
/// assert_eq!(cache.peek_lru(), Some((&1, &"a")));
/// ```
pub fn peek_lru<'a>(&'a self) -> Option<(&'a K, &'a V)> {
pub fn peek_lru(&self) -> Option<(&K, &V)> {
if self.is_empty() {
return None;
}
Expand Down Expand Up @@ -956,7 +956,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// cache.promote(&3);
/// assert_eq!(cache.pop_lru(), Some((1, "a")));
/// ```
pub fn promote<'a, Q>(&'a mut self, k: &Q)
pub fn promote<Q>(&mut self, k: &Q)
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Expand Down Expand Up @@ -992,7 +992,7 @@ impl<K: Hash + Eq, V, S: BuildHasher> LruCache<K, V, S> {
/// assert_eq!(cache.pop_lru(), Some((1, "a")));
/// assert_eq!(cache.pop_lru(), Some((2, "b")));
/// ```
pub fn demote<'a, Q>(&'a mut self, k: &Q)
pub fn demote<Q>(&mut self, k: &Q)
where
K: Borrow<Q>,
Q: Hash + Eq + ?Sized,
Expand Down