From a16aed34dde0913347b8a7429857dffb5d0d44cc Mon Sep 17 00:00:00 2001 From: Mike Pedersen Date: Mon, 5 Mar 2018 20:50:27 +0100 Subject: [PATCH] Changed function param types from Fn to FnMut --- src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f340885c99..c030d7ece3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -218,9 +218,9 @@ where /// /// If the generator function panics while initializing the array, /// any already initialized elements will be dropped. - pub fn generate(f: F) -> GenericArray + pub fn generate(mut f: F) -> GenericArray where - F: Fn(usize) -> T, + F: FnMut(usize) -> T, { let mut destination = ArrayBuilder::new(); @@ -239,7 +239,7 @@ where /// /// The length of the slice *must* be equal to the length of the array. #[inline] - pub fn map_slice T>(s: &[S], f: F) -> GenericArray { + pub fn map_slice T>(s: &[S], mut f: F) -> GenericArray { assert_eq!(s.len(), N::to_usize()); Self::generate(|i| f(unsafe { s.get_unchecked(i) })) @@ -249,9 +249,9 @@ where /// /// If the mapping function panics, any already initialized elements in the new array /// will be dropped, AND any unused elements in the source array will also be dropped. - pub fn map(self, f: F) -> GenericArray + pub fn map(self, mut f: F) -> GenericArray where - F: Fn(T) -> U, + F: FnMut(T) -> U, N: ArrayLength, { let mut source = ArrayConsumer::new(self); @@ -273,9 +273,9 @@ where /// /// If the mapping function panics, any already initialized elements will be dropped. #[inline] - pub fn map_ref(&self, f: F) -> GenericArray + pub fn map_ref(&self, mut f: F) -> GenericArray where - F: Fn(&T) -> U, + F: FnMut(&T) -> U, N: ArrayLength, { GenericArray::generate(|i| f(unsafe { self.get_unchecked(i) })) @@ -286,9 +286,9 @@ where /// /// If the mapping function panics, any already initialized elements in the new array /// will be dropped, AND any unused elements in the source arrays will also be dropped. - pub fn zip(self, rhs: GenericArray, f: F) -> GenericArray + pub fn zip(self, rhs: GenericArray, mut f: F) -> GenericArray where - F: Fn(T, B) -> U, + F: FnMut(T, B) -> U, N: ArrayLength + ArrayLength, { let mut left = ArrayConsumer::new(self); @@ -317,9 +317,9 @@ where /// initializing a new `GenericArray` with the result of the zipped mapping function. /// /// If the mapping function panics, any already initialized elements will be dropped. - pub fn zip_ref(&self, rhs: &GenericArray, f: F) -> GenericArray + pub fn zip_ref(&self, rhs: &GenericArray, mut f: F) -> GenericArray where - F: Fn(&T, &B) -> U, + F: FnMut(&T, &B) -> U, N: ArrayLength + ArrayLength, { GenericArray::generate(|i| unsafe { f(self.get_unchecked(i), rhs.get_unchecked(i)) })