From 955be443291188bf1a40b11b7353bee346183cfc Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Thu, 21 Dec 2023 16:45:08 +0100 Subject: [PATCH 1/2] change update_with to take a FnMut instead of Fn --- src/vec/identified_vec.rs | 4 ++-- src/vec/is_identified_vec.rs | 2 +- src/vec_of/is_identified_vec_of_via.rs | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vec/identified_vec.rs b/src/vec/identified_vec.rs index a759de8..43f2eab 100644 --- a/src/vec/identified_vec.rs +++ b/src/vec/identified_vec.rs @@ -473,9 +473,9 @@ where /// existing element gets updated by `mutate` closure and this function returns /// `true`. #[inline] - fn update_with(&mut self, id: &I, mutate: F) -> bool + fn update_with(&mut self, id: &I, mut mutate: F) -> bool where - F: Fn(&mut E), + F: FnMut(&mut E), { if !self.contains_id(id) { return false; diff --git a/src/vec/is_identified_vec.rs b/src/vec/is_identified_vec.rs index b65c6c5..b8db0ff 100644 --- a/src/vec/is_identified_vec.rs +++ b/src/vec/is_identified_vec.rs @@ -143,7 +143,7 @@ where fn update_with(&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. diff --git a/src/vec_of/is_identified_vec_of_via.rs b/src/vec_of/is_identified_vec_of_via.rs index 34e06f5..e030424 100644 --- a/src/vec_of/is_identified_vec_of_via.rs +++ b/src/vec_of/is_identified_vec_of_via.rs @@ -169,10 +169,11 @@ where self.via_mut().try_update(element) } + #[allow(unused_mut)] #[inline] - fn update_with(&mut self, id: &::ID, mutate: F) -> bool + fn update_with(&mut self, id: &::ID, mut mutate: F) -> bool where - F: Fn(&mut Element), + F: FnMut(&mut Element), { self.via_mut().update_with(id, mutate) } From 267de81eccd4c3653b4b6289b45cae17306e05d0 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Thu, 21 Dec 2023 16:45:34 +0100 Subject: [PATCH 2/2] bump version to 0.1.9 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4345edf..e18efc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "identified_vec" -version = "0.1.8" +version = "0.1.9" dependencies = [ "identified_vec", "serde", diff --git a/Cargo.toml b/Cargo.toml index 96b08d2..6c7235a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "identified_vec" -version = "0.1.8" +version = "0.1.9" edition = "2021" authors = ["Alexander Cyon "] description = "Like HashSet but retaining INSERTION order and without `Hash` requirement on the Element type."