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

ndarray::ArrayViewMut::windows should produce mutable windows #1357

Open
Chris00 opened this issue Feb 5, 2024 · 2 comments
Open

ndarray::ArrayViewMut::windows should produce mutable windows #1357

Chris00 opened this issue Feb 5, 2024 · 2 comments
Labels
design-needed information needed More information is needed to make progress

Comments

@Chris00
Copy link

Chris00 commented Feb 5, 2024

Calling .windows() on an ndarray::ArrayViewMut should return mutable windows. That's very useful when, for example, you iterate over a partition of an interval and the quantities you compute affect values living on both ends of the interval.

@bluss
Copy link
Member

bluss commented Feb 5, 2024

That's not possible by lifetime rules in Rust - the iterator's elements are simultaneously valid, and since they are windows, they partially overlap, which is not allowed for mutable references.

We'll need to update the issue with a plan for a way to get the intended effect in a way we can implement.

@bluss bluss added information needed More information is needed to make progress design-needed labels Mar 2, 2024
@akern40
Copy link
Collaborator

akern40 commented Oct 24, 2024

There is a pattern known as "lending iterators" which allow things like windows_mut. See this article by Niko Matsakis for the general concept, and these crates for implementations of that pattern. We could then support a windows_mut function that returns this kind of iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-needed information needed More information is needed to make progress
Projects
None yet
Development

No branches or pull requests

3 participants