Open
Description
I am trying to move a matrix into an iterator over its rows or columns. row_iter() borrows the matrix, which breaks my usecase:
fn large_f<N, It: Iterator<Item=N>>(matrix_map: impl Fn(Matrix) -> It, mat: Matrix) { ... }
I need a a function that can map a matrix to an iterator for the same operations either on the matrix' rows or columns.
let mat = ...;
large_f(
|mat| mat.row_iter(), // use rows
mat);
large_fn(
|mat| mat.column_iter(), // use columns
mat);
But the error is:
251 | |mat| mat.row_iter(),
| ---^^^^^^^^^^^^^^^^^
| |
| returns a value referencing data owned by the current function
| `mat` is borrowed here
So I would need something like into_row_iter()
which moves out of mat
.