From 48e629fff756724fc16f25a59ca85c78f68e7745 Mon Sep 17 00:00:00 2001 From: Karolin Varner Date: Sun, 20 Oct 2024 21:41:22 +0200 Subject: [PATCH] feat: sideffect/mutating should take FnMut over Fn --- util/src/functional.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/util/src/functional.rs b/util/src/functional.rs index 54ebe8c..183c903 100644 --- a/util/src/functional.rs +++ b/util/src/functional.rs @@ -1,6 +1,6 @@ pub fn mutating(mut v: T, f: F) -> T where - F: Fn(&mut T), + F: FnMut(&mut T), { f(&mut v); v @@ -9,32 +9,32 @@ where pub trait MutatingExt { fn mutating(self, f: F) -> Self where - F: Fn(&mut Self); + F: FnMut(&mut Self); fn mutating_mut(&mut self, f: F) -> &mut Self where - F: Fn(&mut Self); + F: FnMut(&mut Self); } impl MutatingExt for T { fn mutating(self, f: F) -> Self where - F: Fn(&mut Self), + F: FnMut(&mut Self), { mutating(self, f) } - fn mutating_mut(&mut self, f: F) -> &mut Self + fn mutating_mut(&mut self, mut f: F) -> &mut Self where - F: Fn(&mut Self), + F: FnMut(&mut Self), { f(self); self } } -pub fn sideeffect(v: T, f: F) -> T +pub fn sideeffect(v: T, mut f: F) -> T where - F: Fn(&T), + F: FnMut(&T), { f(&v); v @@ -43,34 +43,34 @@ where pub trait SideffectExt { fn sideeffect(self, f: F) -> Self where - F: Fn(&Self); + F: FnMut(&Self); fn sideeffect_ref(&self, f: F) -> &Self where - F: Fn(&Self); + F: FnMut(&Self); fn sideeffect_mut(&mut self, f: F) -> &mut Self where - F: Fn(&Self); + F: FnMut(&Self); } impl SideffectExt for T { fn sideeffect(self, f: F) -> Self where - F: Fn(&Self), + F: FnMut(&Self), { sideeffect(self, f) } - fn sideeffect_ref(&self, f: F) -> &Self + fn sideeffect_ref(&self, mut f: F) -> &Self where - F: Fn(&Self), + F: FnMut(&Self), { f(self); self } - fn sideeffect_mut(&mut self, f: F) -> &mut Self + fn sideeffect_mut(&mut self, mut f: F) -> &mut Self where - F: Fn(&Self), + F: FnMut(&Self), { f(self); self