Skip to content

Commit c16b587

Browse files
committed
Make function arguments FnMut
Closes #59
1 parent 805d8c8 commit c16b587

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/functional.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub unsafe trait FunctionalSequence<T>: GenericSequence<T> {
3737
where
3838
Self: MappedGenericSequence<T, U>,
3939
Self::Length: ArrayLength<U>,
40-
F: Fn(SequenceItem<Self>) -> U,
40+
F: FnMut(SequenceItem<Self>) -> U,
4141
{
4242
FromIterator::from_iter(self.into_iter().map(f))
4343
}
@@ -47,12 +47,12 @@ pub unsafe trait FunctionalSequence<T>: GenericSequence<T> {
4747
///
4848
/// If the mapping function panics, any already initialized elements in the new sequence
4949
/// will be dropped, AND any unused elements in the source sequences will also be dropped.
50-
fn zip<B, Rhs, U, F>(self, rhs: Rhs, f: F) -> MappedSequence<Self, T, U>
50+
fn zip<B, Rhs, U, F>(self, rhs: Rhs, mut f: F) -> MappedSequence<Self, T, U>
5151
where
5252
Self: MappedGenericSequence<T, U>,
5353
Self::Length: ArrayLength<B> + ArrayLength<U>,
5454
Rhs: GenericSequence<B>,
55-
F: Fn(SequenceItem<Self>, SequenceItem<Rhs>) -> U,
55+
F: FnMut(SequenceItem<Self>, SequenceItem<Rhs>) -> U,
5656
{
5757
FromIterator::from_iter(self.into_iter().zip(rhs.into_iter()).map(|(l, r)| f(l, r) ))
5858
}

src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ where
281281
type Length = N;
282282
type Sequence = Self;
283283

284-
fn generate<F>(f: F) -> GenericArray<T, N>
284+
fn generate<F>(mut f: F) -> GenericArray<T, N>
285285
where
286-
F: Fn(usize) -> T,
286+
F: FnMut(usize) -> T,
287287
{
288288
let mut destination = ArrayBuilder::new();
289289

@@ -312,11 +312,11 @@ where
312312
N: ArrayLength<T>,
313313
Self: GenericSequence<T, Item=T>
314314
{
315-
fn map<U, F>(self, f: F) -> MappedSequence<Self, T, U>
315+
fn map<U, F>(self, mut f: F) -> MappedSequence<Self, T, U>
316316
where
317317
Self::Length: ArrayLength<U>,
318318
Self: MappedGenericSequence<T, U>,
319-
F: Fn(T) -> U,
319+
F: FnMut(T) -> U,
320320
{
321321
let mut source = ArrayConsumer::new(self);
322322

@@ -331,12 +331,12 @@ where
331331
}))
332332
}
333333

334-
fn zip<B, Rhs, U, F>(self, rhs: Rhs, f: F) -> MappedSequence<Self, T, U>
334+
fn zip<B, Rhs, U, F>(self, rhs: Rhs, mut f: F) -> MappedSequence<Self, T, U>
335335
where
336336
Self: MappedGenericSequence<T, U>,
337337
Self::Length: ArrayLength<B> + ArrayLength<U>,
338338
Rhs: GenericSequence<B>,
339-
F: Fn(T, SequenceItem<Rhs>) -> U,
339+
F: FnMut(T, SequenceItem<Rhs>) -> U,
340340
{
341341
let mut left = ArrayConsumer::new(self);
342342

src/sequence.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub unsafe trait GenericSequence<T>: Sized + IntoIterator {
2020
/// If the generator function panics while initializing the sequence,
2121
/// any already initialized elements will be dropped.
2222
fn generate<F>(f: F) -> Self::Sequence
23-
where F: Fn(usize) -> T;
23+
where F: FnMut(usize) -> T;
2424
}
2525

2626
/// Accessor type for iteration items from `GenericSequence`
@@ -35,7 +35,7 @@ where
3535

3636
#[inline]
3737
fn generate<F>(f: F) -> Self::Sequence
38-
where F: Fn(usize) -> T
38+
where F: FnMut(usize) -> T
3939
{
4040
S::generate(f)
4141
}
@@ -50,7 +50,7 @@ where
5050

5151
#[inline]
5252
fn generate<F>(f: F) -> Self::Sequence
53-
where F: Fn(usize) -> T
53+
where F: FnMut(usize) -> T
5454
{
5555
S::generate(f)
5656
}

0 commit comments

Comments
 (0)