Description
Location
https://doc.rust-lang.org/core/primitive.slice.html#method.windows
Summary
The documentation for slice::windows
states:
There’s no windows_mut, as that existing would let safe code violate the “only one &mut at a time to the same thing” rule.
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 in slice::window
.