@@ -1180,9 +1180,11 @@ use indexes::IndicesIterF;
1180
1180
1181
1181
unsafe impl < F > TrustedIterator for Linspace < F > { }
1182
1182
unsafe impl < ' a , A , D > TrustedIterator for Iter < ' a , A , D > { }
1183
+ unsafe impl < ' a , A , D > TrustedIterator for IterMut < ' a , A , D > { }
1183
1184
unsafe impl < I , F > TrustedIterator for std:: iter:: Map < I , F >
1184
1185
where I : TrustedIterator { }
1185
1186
unsafe impl < ' a , A > TrustedIterator for slice:: Iter < ' a , A > { }
1187
+ unsafe impl < ' a , A > TrustedIterator for slice:: IterMut < ' a , A > { }
1186
1188
unsafe impl TrustedIterator for :: std:: ops:: Range < usize > { }
1187
1189
// FIXME: These indices iter are dubious -- size needs to be checked up front.
1188
1190
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>
1219
1221
debug_assert_eq ! ( size, result. len( ) ) ;
1220
1222
result
1221
1223
}
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