You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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<Item = (u8,u8)> + '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 #1315 which is also needed for this code to work. (So you need the current main branch otherwise you get different lifetime errors)
The text was updated successfully, but these errors were encountered:
There are several issues here, and I'm not quite sure if we can really resolve them. Most of these methods, such as column are methods on the very generic Matrix type. That also includes owned matrices, so column in its current form can never return a lifetime longer than &self, since then it would not be applicable to owned matrices.
I think your could could work if you rather take matrix by reference though. Could this help your use cases? I prefer to take views by value, so I absolutely sympathize, however.
Take the
column()
function as an example.If it is called on a
MatrixView
the lifetime annotations are too restrictive.Take this code as an example:
The problem is that
column
takes a reference to the parametermatrix
, soleft_half
has a lifetime tomatrix
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 #1315 which is also needed for this code to work. (So you need the current main branch otherwise you get different lifetime errors)
The text was updated successfully, but these errors were encountered: