Skip to content

Commit 7fe9910

Browse files
authored
Clarify WindowsMut (Lending)Iterator
fixes 133628
1 parent b5741a3 commit 7fe9910

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/core/src/slice/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,10 +1099,12 @@ impl<T> [T] {
10991099
/// assert!(iter.next().is_none());
11001100
/// ```
11011101
///
1102-
/// There's no `windows_mut`, as that existing would let safe code violate the
1103-
/// "only one `&mut` at a time to the same thing" rule. However, you can sometimes
1104-
/// use [`Cell::as_slice_of_cells`](crate::cell::Cell::as_slice_of_cells) in
1102+
/// There's no `windows_mut` Iterator-equivalent of `windows`,
1103+
/// (as `[0,1,2].windows_mut(2).collect()` would create 2 mutable references to the middle elements of that array),
1104+
/// though a [LendingIterator]-equivalent is possible.
1105+
/// However, you can sometimes use [`Cell::as_slice_of_cells`](crate::cell::Cell::as_slice_of_cells) in
11051106
/// conjunction with `windows` to accomplish something similar:
1107+
/// [LendingIterator]: https://blog.rust-lang.org/2022/10/28/gats-stabilization.html
11061108
/// ```
11071109
/// use std::cell::Cell;
11081110
///

0 commit comments

Comments
 (0)