File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -640,6 +640,11 @@ impl<T> [T] {
640640 /// Calling this method with an out-of-bounds index is *[undefined behavior]*
641641 /// even if the resulting reference is not used.
642642 ///
643+ /// You can think of this like `.get(index).unwrap_unchecked()`. It's UB
644+ /// to call `.get_unchecked(len)`, even if you immediately convert to a
645+ /// pointer. And it's UB to call `.get_unchecked(..len +1)` or
646+ /// `.get_unchecked(..=len)` similar.
647+ ///
643648 /// [`get`]: slice::get
644649 /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
645650 ///
@@ -675,6 +680,11 @@ impl<T> [T] {
675680 /// Calling this method with an out-of-bounds index is *[undefined behavior]*
676681 /// even if the resulting reference is not used.
677682 ///
683+ /// You can think of this like `.get_mut(index).unwrap_unchecked()`. It's
684+ /// UB to call `.get_unchecked_mut(len)`, even if you immediately convert
685+ /// to a pointer. And it's UB to call `.get_unchecked_mut(..len +1)` or
686+ /// `.get_unchecked_mut(..=len)` similar.
687+ ///
678688 /// [`get_mut`]: slice::get_mut
679689 /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
680690 ///
You can’t perform that action at this time.
0 commit comments