dimforge / dimforge/nalgebra

Owned RowIter/ColumnIter, Matrix::into_row_iter()/into_column_iter()

Open
#834 1 comment 2 reactions 0 assignees View on GitHub
enhancement good first issue P-medium
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

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:
```rust
fn large_f>(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.
```rust
let mat = ...;
large_f(
|mat| mat.row_iter(), // use rows
mat);
large_fn(
|mat| mat.column_iter(), // use columns
mat);
```
But the error is:
```rust
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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.