All FnMut in some maps

Tue, 04 Aug 2026 14:53:58 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Tue, 04 Aug 2026 14:53:58 -0500
changeset 204
016122e0384b
parent 203
ad16acf47726
child 205
30af49ae2135

All FnMut in some maps

src/maputil.rs file | annotate | diff | comparison | revisions
src/sets/cube.rs file | annotate | diff | comparison | revisions
--- a/src/maputil.rs	Mon Aug 03 19:26:21 2026 -0500
+++ b/src/maputil.rs	Tue Aug 04 14:53:58 2026 -0500
@@ -80,7 +80,7 @@
         >(
             $var0 : $ctype0,
             $($var : $ctype,)*
-            f : impl Fn($etype0, $($etype),*) -> Res
+            mut f : impl FnMut($etype0, $($etype),*) -> Res
         ) -> [Res; N] {
             let zipit = izip!($var0.fl_iter(), $($var.fl_iter()),*);
             let map = zipit.map(|tuple_or_singleton!($var0, $($var),*)| f($var0, $($var),*));
@@ -99,7 +99,7 @@
         >(
             $var0 : $ctype0,
             $($var : $ctype,)*
-            f : impl Fn(usize, $etype0, $($etype),*) -> Res
+            mut f : impl FnMut(usize, $etype0, $($etype),*) -> Res
         ) -> [Res; N] {
             let zipit = (0..N).zip(izip!($var0.fl_iter(), $($var.fl_iter()),*));
             let map = zipit.map(|(i, tuple_or_singleton!($var0, $($var),*))| f(i, $var0, $($var),*));
@@ -263,11 +263,7 @@
         F: Fn(usize, &'a A) -> B;
     #[inline]
     fn indexmap<B, F: Fn(usize, &'a A) -> B>(self, f: F) -> Self::Output<B, F> {
-        IndexMap {
-            iter: self,
-            j: 0,
-            f,
-        }
+        IndexMap { iter: self, j: 0, f }
     }
 }
 
@@ -289,11 +285,7 @@
         F: Fn(usize, A) -> B;
     #[inline]
     fn indexmap<B, F: Fn(usize, A) -> B>(self, f: F) -> Self::Output<B, F> {
-        IndexMap {
-            iter: self,
-            j: 0,
-            f,
-        }
+        IndexMap { iter: self, j: 0, f }
     }
 }
 
@@ -382,10 +374,7 @@
     }
 
     let mut array = [const { MaybeUninit::uninit() }; N];
-    let mut guard = Guard {
-        array_mut: &mut array,
-        initialized: 0,
-    };
+    let mut guard = Guard { array_mut: &mut array, initialized: 0 };
 
     while let Some(item) = iter.next() {
         // SAFETY: `guard.initialized` starts at 0, is increased by one in the
--- a/src/sets/cube.rs	Mon Aug 03 19:26:21 2026 -0500
+++ b/src/sets/cube.rs	Tue Aug 04 14:53:58 2026 -0500
@@ -97,14 +97,14 @@
     /// Maps `f` over the triples $\\{(i, a\_i, b\_i)\\}\_{i=1}^N$
     /// of the cube $∏_{i=1}^N [a_i, b_i)$.
     #[inline]
-    pub fn map_indexed<T>(&self, f: impl Fn(usize, U, U) -> T) -> [T; N] {
+    pub fn map_indexed<T>(&self, mut f: impl FnMut(usize, U, U) -> T) -> [T; N] {
         map1_indexed(self, |i, &[a, b]| f(i, a, b))
     }
 
     /// Maps `f` over the tuples $\\{(a\_i, b\_i)\\}\_{i=1}^N$
     /// of the cube $∏_{i=1}^N [a_i, b_i)$.
     #[inline]
-    pub fn map<T>(&self, f: impl Fn(U, U) -> T) -> [T; N] {
+    pub fn map<T>(&self, mut f: impl FnMut(U, U) -> T) -> [T; N] {
         map1(self, |&[a, b]| f(a, b))
     }
 
@@ -145,10 +145,7 @@
     /// $∏_{i=1}^N [a_i, b_i)$.
     #[inline]
     pub fn iter_corners(&self) -> CubeCornersIter<'_, U, N> {
-        CubeCornersIter {
-            index: 0,
-            cube: self,
-        }
+        CubeCornersIter { index: 0, cube: self }
     }
 
     /// Returns the width-`N`-tuple $(b_1-a_1, … ,b_N-a_N)$ of the cube $∏_{i=1}^N [a_i, b_i)$.

mercurial