From 7fe602c3d69dd2c0417a7509e15f4cba68bafce0 Mon Sep 17 00:00:00 2001 From: elftausend <76885970+elftausend@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:16:35 +0200 Subject: [PATCH] Use Fn instead of FnMut in Cursor::cached --- src/cache/owned_cache/fast_cache.rs | 9 +++++---- src/features.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cache/owned_cache/fast_cache.rs b/src/cache/owned_cache/fast_cache.rs index 84eb6aff..d29c9e3d 100644 --- a/src/cache/owned_cache/fast_cache.rs +++ b/src/cache/owned_cache/fast_cache.rs @@ -196,6 +196,7 @@ mod tests { for _ in 0..10 { dev.cached(|| { + let mut _buf: Option> = None; _buf = dev.retrieve(10, ()).ok(); _buf = dev.retrieve(10, ()).ok(); _buf = dev.retrieve(10, ()).ok(); @@ -217,16 +218,16 @@ mod tests { for _ in 0..10 { dev.cached(|| { - _buf = dev.retrieve(10, ()).ok(); + let _buf: Option> = dev.retrieve(10, ()).ok(); }); dev.cached(|| { - _buf = dev.retrieve(10, ()).ok(); + let _buf: Option> = dev.retrieve(10, ()).ok(); }); dev.cached(|| { - _buf = dev.retrieve(10, ()).ok(); + let _buf: Option> = dev.retrieve(10, ()).ok(); }); let nodes = &dev.modules.cache.borrow().nodes; - assert_eq!(nodes.len(), 4); + assert_eq!(nodes.len(), 2); } } } diff --git a/src/features.rs b/src/features.rs index 8f54cd5e..6f4ae691 100644 --- a/src/features.rs +++ b/src/features.rs @@ -80,7 +80,7 @@ pub trait Cursor { } #[inline] - fn cached(&self, mut cb: impl FnMut()) + fn cached(&self, cb: impl Fn()) where Self: Sized, {