Owned MatrixView Lifetime issues
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Take the [`column()`](https://docs.rs/nalgebra/latest/nalgebra/base/struct.Matrix.html#method.column) function as an example.
If it is called on a `MatrixView` the lifetime annotations are too restrictive.
Take this code as an example:
```
fn get_column_iter<'a>(
matrix: na::DMatrixView<'a, u8>,
column_id: (usize, usize),
) -> impl Iterator + 'a {
let (left_id, right_id) = column_id;
let left_half = matrix.column(left_id).into_iter();
let right_half = matrix.column(right_id).into_iter();
std::iter::zip(left_half, right_half)
}
```
The problem is that `column` takes a reference to the parameter `matrix`, so `left_half` has a lifetime to `matrix` but it should have the lifetime `'a`
So if `column` (and other function which creates MatrixViews) should propagate the lifetime of the MatrixView on which they are called and not the lifetime of the reference to the MatrixView.
This is similar to https://github.com/dimforge/nalgebra/pull/1315 which is also needed for this code to work. (So you need the current main branch otherwise you get different lifetime errors)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.