-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Feature request] Add [T]::windows_mut #23783
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I think that this would actually be unsound to implement. Each window is overlapping, and I believe that there's currently no guarantee that you can't do something like: let mut parts = slice.windows_mut(4);
let part1 = parts.next().unwrap();
let part2 = parts.next().unwrap();
// part1/part2 overlap I believe this is why iterators like |
Is it possible to write in a way that the result of |
I believe that due to the signature of |
(This is an example of something that could be tackled via "streaming iterators" e.g. https://github.com/emk/rust-streaming .) |
@huonw is right but his link is broken 😄 |
Ah, github incorrectly included the trailing |
Small API enhancements aren't tracked these days; we instead just accept PRs. Apparently this is blocked on streaming iterators, so a PR can't be sent in right now, but we still don't track random stuff like this. Closing! |
Mention the lack of `windows_mut` in `windows` This is a common request, going back to at least 2015 (rust-lang#23783), so mention in the docs that it can't be done and offer a workaround using <https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells>. (See also URLO threads like <https://internals.rust-lang.org/t/a-windows-mut-method-on-slice/16941/10?u=scottmcm>.)
When borrows are involved, it is a common pattern to have a
foo_mut
variation offoo
method. For example,[T]
slices have achunks
method that takes&self
and returns an iterator of&[T]
, and achunks_mut
method that is identical except that it takes&mut self
and returns an iterator of&mut [T]
.The
windows
method similarly takes&self
and return an iterator of&[T]
. However, the correspondingwindows_mut
does not exist, although it could sometimes be useful.The text was updated successfully, but these errors were encountered: