Apply suggestions from code review

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
This commit is contained in:
Ralf Jung 2019-08-03 13:45:15 +02:00 committed by GitHub
parent f44abba4ec
commit 3b9cda4693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -293,11 +293,12 @@ impl<T> [T] {
/// checking.
///
/// This is generally not recommended, use with caution!
/// Calling this method with an out-of-bounds index is UB even if the resulting
/// reference is not used.
/// Calling this method with an out-of-bounds index is *[undefined behavior]*
/// even if the resulting reference is not used.
/// For a safe alternative see [`get`].
///
/// [`get`]: #method.get
/// [undefined behavior]: ../../reference/behavior-considered-undefined.html
///
/// # Examples
///
@ -320,11 +321,12 @@ impl<T> [T] {
/// bounds checking.
///
/// This is generally not recommended, use with caution!
/// Calling this method with an out-of-bounds index is UB even if the resulting
/// reference is not used.
/// Calling this method with an out-of-bounds index is *[undefined behavior]*
/// even if the resulting reference is not used.
/// For a safe alternative see [`get_mut`].
///
/// [`get_mut`]: #method.get_mut
/// [undefined behavior]: ../../reference/behavior-considered-undefined.html
///
/// # Examples
///
@ -2633,15 +2635,17 @@ pub trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
/// Returns a shared reference to the output at this location, without
/// performing any bounds checking.
/// Calling this method with an out-of-bounds index is UB even if the resulting
/// reference is not used.
/// Calling this method with an out-of-bounds index is *[undefined behavior]*
/// even if the resulting reference is not used.
/// [undefined behavior]: ../../reference/behavior-considered-undefined.html
#[unstable(feature = "slice_index_methods", issue = "0")]
unsafe fn get_unchecked(self, slice: &T) -> &Self::Output;
/// Returns a mutable reference to the output at this location, without
/// performing any bounds checking.
/// Calling this method with an out-of-bounds index is UB even if the resulting
/// reference is not used.
/// Calling this method with an out-of-bounds index is *[undefined behavior]*
/// even if the resulting reference is not used.
/// [undefined behavior]: ../../reference/behavior-considered-undefined.html
#[unstable(feature = "slice_index_methods", issue = "0")]
unsafe fn get_unchecked_mut(self, slice: &mut T) -> &mut Self::Output;