Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Owned MatrixView Lifetime issues #1393

Open
benjamin-lieser opened this issue May 15, 2024 · 0 comments
Open

Owned MatrixView Lifetime issues #1393

benjamin-lieser opened this issue May 15, 2024 · 0 comments

Comments

@benjamin-lieser
Copy link

benjamin-lieser commented May 15, 2024

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:

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant