Clarify UB in get_unchecked(_mut)
· rust-lang/rust@2c13ee8 (original) (raw)
`@@ -640,6 +640,11 @@ impl [T] {
`
640
640
`/// Calling this method with an out-of-bounds index is [undefined behavior]
`
641
641
`/// even if the resulting reference is not used.
`
642
642
`///
`
``
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
`+
///
`
643
648
`` /// [get
]: slice::get
``
644
649
`/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
`
645
650
`///
`
`@@ -675,6 +680,11 @@ impl [T] {
`
675
680
`/// Calling this method with an out-of-bounds index is [undefined behavior]
`
676
681
`/// even if the resulting reference is not used.
`
677
682
`///
`
``
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
`+
///
`
678
688
`` /// [get_mut
]: slice::get_mut
``
679
689
`/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
`
680
690
`///
`