Skip to content

Clarify statement regarding windows_mut #133628

Closed
@Voultapher

Description

@Voultapher

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions