@@ -213,7 +213,7 @@ where D: Dimension
213213 }
214214}
215215
216- /// Methods for iterating over array views
216+ /// Methods for iterating over array views.
217217impl < ' a , A , D > ArrayView < ' a , A , D >
218218where D : Dimension
219219{
@@ -229,17 +229,47 @@ where D: Dimension
229229 ElementsBase :: new ( self )
230230 }
231231
232- /// Return an outer iterator for this view, but with the lifetime
233- /// of the view's data.
232+ /// Convert into an outer iterator for this view.
234233 ///
235- /// See [ArrayRef::outer_iter] for details.
234+ /// Unlike [ArrayRef::outer_iter], this methods preserves the lifetime of the data,
235+ /// not the view itself.
236236 pub fn into_outer_iter ( self ) -> iter:: AxisIter < ' a , A , D :: Smaller >
237237 where D : RemoveAxis
238238 {
239239 AxisIter :: new ( self , Axis ( 0 ) )
240240 }
241+
242+ /// Convert into an indexed iterator.
243+ ///
244+ /// Unlike [ArrayRef::indexed_iter], this methods preserves the lifetime of the data,
245+ /// not the view itself.
246+ pub fn into_indexed_iter ( self ) -> iter:: IndexedIter < ' a , A , D >
247+ {
248+ iter:: IndexedIter :: new ( self . into_elements_base ( ) )
249+ }
250+
251+ /// Convert into an iterator over an `axis`.
252+ ///
253+ /// Unlike [ArrayRef::axis_iter], this methods preserves the lifetime of the data,
254+ /// not the view itself.
255+ pub fn into_axis_iter ( self , axis : Axis ) -> iter:: AxisIter < ' a , A , D :: Smaller >
256+ where D : RemoveAxis
257+ {
258+ AxisIter :: new ( self , axis)
259+ }
260+
261+ /// Convert into an iterator over an `axis` by chunks.
262+ ///
263+ /// Unlike [`ArrayRef::axis_chunks_iter`], this methods preserves the lifetime of the data,
264+ /// not the view itself.
265+ pub fn into_axis_chunks_iter ( self , axis : Axis , chunk_size : usize ) -> iter:: AxisChunksIter < ' a , A , D >
266+ where D : RemoveAxis
267+ {
268+ iter:: AxisChunksIter :: new ( self , axis, chunk_size)
269+ }
241270}
242271
272+ /// Methods for iterating over mutable array views.
243273impl < ' a , A , D > ArrayViewMut < ' a , A , D >
244274where D : Dimension
245275{
@@ -290,17 +320,81 @@ where D: Dimension
290320 }
291321 }
292322
293- pub ( crate ) fn into_iter_ ( self ) -> IterMut < ' a , A , D >
323+ /// Convert into an outer iterator for this view.
324+ ///
325+ /// Unlike [ArrayRef::outer_iter], this methods preserves the lifetime of the data,
326+ /// not the view itself.
327+ pub fn into_outer_iter ( self ) -> iter:: AxisIter < ' a , A , D :: Smaller >
328+ where D : RemoveAxis
329+ {
330+ AxisIter :: new ( self . into_view ( ) , Axis ( 0 ) )
331+ }
332+
333+ /// Convert into an indexed iterator.
334+ ///
335+ /// Unlike [ArrayRef::indexed_iter], this methods preserves the lifetime of the data,
336+ /// not the view itself.
337+ pub fn into_indexed_iter ( self ) -> iter:: IndexedIter < ' a , A , D >
338+ {
339+ iter:: IndexedIter :: new ( self . into_view ( ) . into_elements_base ( ) )
340+ }
341+
342+ /// Convert into an iterator over an `axis`.
343+ ///
344+ /// Unlike [ArrayRef::axis_iter], this methods preserves the lifetime of the data,
345+ /// not the view itself.
346+ pub fn into_axis_iter ( self , axis : Axis ) -> iter:: AxisIter < ' a , A , D :: Smaller >
347+ where D : RemoveAxis
348+ {
349+ AxisIter :: new ( self . into_view ( ) , axis)
350+ }
351+
352+ /// Convert into an iterator over an `axis` by chunks.
353+ ///
354+ /// Unlike [`ArrayRef::axis_chunks_iter`], this methods preserves the lifetime of the data,
355+ /// not the view itself.
356+ pub fn into_axis_chunks_iter ( self , axis : Axis , chunk_size : usize ) -> iter:: AxisChunksIter < ' a , A , D >
357+ where D : RemoveAxis
294358 {
295- IterMut :: new ( self )
359+ iter :: AxisChunksIter :: new ( self . into_view ( ) , axis , chunk_size )
296360 }
297361
298- /// Return an outer iterator for this view.
299- #[ doc( hidden) ] // not official
300- #[ deprecated( note = "This method will be replaced." ) ]
301- pub fn into_outer_iter ( self ) -> iter:: AxisIterMut < ' a , A , D :: Smaller >
362+ /// Convert into an outer iterator for this view.
363+ ///
364+ /// Unlike [ArrayRef::outer_iter_mut], this methods preserves the lifetime of the data,
365+ /// not the view itself.
366+ pub fn into_outer_iter_mut ( self ) -> iter:: AxisIterMut < ' a , A , D :: Smaller >
302367 where D : RemoveAxis
303368 {
304369 AxisIterMut :: new ( self , Axis ( 0 ) )
305370 }
371+
372+ /// Convert into an indexed iterator.
373+ ///
374+ /// Unlike [ArrayRef::indexed_iter_mut], this methods preserves the lifetime of the data,
375+ /// not the view itself.
376+ pub fn into_indexed_iter_mut ( self ) -> iter:: IndexedIterMut < ' a , A , D >
377+ {
378+ iter:: IndexedIterMut :: new ( self . into_elements_base ( ) )
379+ }
380+
381+ /// Convert into an iterator over an `axis`.
382+ ///
383+ /// Unlike [ArrayRef::axis_iter_mut], this methods preserves the lifetime of the data,
384+ /// not the view itself.
385+ pub fn into_axis_iter_mut ( self , axis : Axis ) -> iter:: AxisIterMut < ' a , A , D :: Smaller >
386+ where D : RemoveAxis
387+ {
388+ AxisIterMut :: new ( self , axis)
389+ }
390+
391+ /// Convert into an iterator over an `axis` by chunks.
392+ ///
393+ /// Unlike [`ArrayRef::axis_chunks_iter_mut`], this methods preserves the lifetime of the data,
394+ /// not the view itself.
395+ pub fn into_axis_chunks_iter_mut ( self , axis : Axis , chunk_size : usize ) -> iter:: AxisChunksIterMut < ' a , A , D >
396+ where D : RemoveAxis
397+ {
398+ iter:: AxisChunksIterMut :: new ( self , axis, chunk_size)
399+ }
306400}
0 commit comments