Skip to content

Commit b7476f1

Browse files
Rollup merge of #135773 - hkBst:patch-10, r=tgross35
Clarify WindowsMut (Lending)Iterator fixes #133628
2 parents f753850 + f630f7f commit b7476f1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

library/core/src/slice/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1099,10 +1099,15 @@ 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
1105-
/// conjunction with `windows` to accomplish something similar:
1102+
/// Because the [Iterator] trait cannot represent the required lifetimes,
1103+
/// there is no `windows_mut` analog to `windows`;
1104+
/// `[0,1,2].windows_mut(2).collect()` would violate [the rules of references]
1105+
/// (though a [LendingIterator] analog is possible). You can sometimes use
1106+
/// [`Cell::as_slice_of_cells`](crate::cell::Cell::as_slice_of_cells) in
1107+
/// conjunction with `windows` instead:
1108+
///
1109+
/// [the rules of references]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#the-rules-of-references
1110+
/// [LendingIterator]: https://blog.rust-lang.org/2022/10/28/gats-stabilization.html
11061111
/// ```
11071112
/// use std::cell::Cell;
11081113
///

0 commit comments

Comments
 (0)