Skip to content

Commit

Permalink
Merge pull request #12 from Sajjon/fn_mut
Browse files Browse the repository at this point in the history
Fn mut
  • Loading branch information
Sajjon authored Dec 21, 2023
2 parents 99b7d22 + 267de81 commit a4cce78
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "identified_vec"
version = "0.1.8"
version = "0.1.9"
edition = "2021"
authors = ["Alexander Cyon <alex.cyon@gmail.com>"]
description = "Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type."
Expand Down
4 changes: 2 additions & 2 deletions src/vec/identified_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ where
/// existing element gets updated by `mutate` closure and this function returns
/// `true`.
#[inline]
fn update_with<F>(&mut self, id: &I, mutate: F) -> bool
fn update_with<F>(&mut self, id: &I, mut mutate: F) -> bool
where
F: Fn(&mut E),
F: FnMut(&mut E),
{
if !self.contains_id(id) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/vec/is_identified_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where

fn update_with<F>(&mut self, id: &ID, mutate: F) -> bool
where
F: Fn(&mut Element);
F: FnMut(&mut Element);

/// Insert a new member to this identified_vec at the specified index, if the identified_vec doesn't already contain
/// it.
Expand Down
5 changes: 3 additions & 2 deletions src/vec_of/is_identified_vec_of_via.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ where
self.via_mut().try_update(element)
}

#[allow(unused_mut)]
#[inline]
fn update_with<F>(&mut self, id: &<Element as Identifiable>::ID, mutate: F) -> bool
fn update_with<F>(&mut self, id: &<Element as Identifiable>::ID, mut mutate: F) -> bool
where
F: Fn(&mut Element),
F: FnMut(&mut Element),
{
self.via_mut().update_with(id, mutate)
}
Expand Down

0 comments on commit a4cce78

Please # to comment.