Skip to content

Commit

Permalink
Use Fn instead of FnMut in Cursor::cached
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Oct 3, 2024
1 parent 75fa692 commit 7fe602c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/cache/owned_cache/fast_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ mod tests {

for _ in 0..10 {
dev.cached(|| {
let mut _buf: Option<Buffer<f32, _>> = None;
_buf = dev.retrieve(10, ()).ok();
_buf = dev.retrieve(10, ()).ok();
_buf = dev.retrieve(10, ()).ok();
Expand All @@ -217,16 +218,16 @@ mod tests {

for _ in 0..10 {
dev.cached(|| {
_buf = dev.retrieve(10, ()).ok();
let _buf: Option<Buffer<f32, _>> = dev.retrieve(10, ()).ok();
});
dev.cached(|| {
_buf = dev.retrieve(10, ()).ok();
let _buf: Option<Buffer<f32, _>> = dev.retrieve(10, ()).ok();
});
dev.cached(|| {
_buf = dev.retrieve(10, ()).ok();
let _buf: Option<Buffer<f32, _>> = dev.retrieve(10, ()).ok();
});
let nodes = &dev.modules.cache.borrow().nodes;
assert_eq!(nodes.len(), 4);
assert_eq!(nodes.len(), 2);
}
}
}
2 changes: 1 addition & 1 deletion src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait Cursor {
}

#[inline]
fn cached(&self, mut cb: impl FnMut())
fn cached(&self, cb: impl Fn())
where
Self: Sized,
{
Expand Down

0 comments on commit 7fe602c

Please sign in to comment.