Skip to content

Commit 3de28af

Browse files
Removed useless . Implemented TrustedIterator for IterMut and slice::IterMut
1 parent fa0c85c commit 3de28af

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/iterators/mod.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,11 @@ use indexes::IndicesIterF;
11801180

11811181
unsafe impl<F> TrustedIterator for Linspace<F> { }
11821182
unsafe impl<'a, A, D> TrustedIterator for Iter<'a, A, D> { }
1183+
unsafe impl<'a, A, D> TrustedIterator for IterMut<'a, A, D> { }
11831184
unsafe impl<I, F> TrustedIterator for std::iter::Map<I, F>
11841185
where I: TrustedIterator { }
11851186
unsafe impl<'a, A> TrustedIterator for slice::Iter<'a, A> { }
1187+
unsafe impl<'a, A> TrustedIterator for slice::IterMut<'a, A> { }
11861188
unsafe impl TrustedIterator for ::std::ops::Range<usize> { }
11871189
// FIXME: These indices iter are dubious -- size needs to be checked up front.
11881190
unsafe impl<D> TrustedIterator for IndicesIter<D> where D: Dimension { }
@@ -1219,27 +1221,3 @@ pub fn to_vec_mapped<I, F, B>(iter: I, mut f: F) -> Vec<B>
12191221
debug_assert_eq!(size, result.len());
12201222
result
12211223
}
1222-
1223-
/// Like Iterator::collect, but only for trusted length iterators
1224-
pub fn to_vec_mapped_mut<I, F, B>(iter: I, mut f: F) -> Vec<B>
1225-
where I: TrustedIterator + ExactSizeIterator,
1226-
F: FnMut(&mut I::Item) -> B,
1227-
{
1228-
// Use an `unsafe` block to do this efficiently.
1229-
// We know that iter will produce exactly .size() elements,
1230-
// and the loop can vectorize if it's clean (without branch to grow the vector).
1231-
let (size, _) = iter.size_hint();
1232-
let mut result = Vec::with_capacity(size);
1233-
let mut out_ptr = result.as_mut_ptr();
1234-
let mut len = 0;
1235-
iter.fold((), |(), elt| {
1236-
unsafe {
1237-
ptr::write(out_ptr, f(&mut elt));
1238-
len += 1;
1239-
result.set_len(len);
1240-
out_ptr = out_ptr.offset(1);
1241-
}
1242-
});
1243-
debug_assert_eq!(size, result.len());
1244-
result
1245-
}

0 commit comments

Comments
 (0)