-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clarify statement regarding windows_mut
#133628
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
Comments
You seem to be confusing For exampleFrom the
(Note how ((Chunks don't overlap and
The
(There is no lending iterator trait in |
I think that was the missing piece for me, each individual iteration is valid but only if it has a unique borrow per iteration, the original documentation piece only talks about Can we find a wording of that phrase that makes the idea behind it more clear? |
This is not correct. The |
Rollup merge of rust-lang#135773 - hkBst:patch-10, r=tgross35 Clarify WindowsMut (Lending)Iterator fixes rust-lang#133628
Clarify WindowsMut (Lending)Iterator fixes rust-lang#133628
Location
https://doc.rust-lang.org/core/primitive.slice.html#method.windows
Summary
The documentation for
slice::windows
states:Either I don't understand how it would violate the unique reference rules of Rust or that statement is false. Using GATs it's possible to implement a version of
windows_mut
today as shown here, however that version is limited to slice windows of size known at compile time. But that limitation doesn't change the fact that it is - at leas to my understanding - perfectly fine to have multiple unique references to slice elements as long as they are not pointing to the same element, which can't happen by definition inslice::window
.The text was updated successfully, but these errors were encountered: