diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 9e452f577b7dd..0dce766eaf486 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -3078,10 +3078,11 @@ impl [T] { left } - /// Removes and returns the portion of the slice specified by `range`. + /// Returns the subslice corresponding to the given range, + /// and modifies the slice to no longer include this subslice. /// - /// If the provided `range` starts or ends outside of the slice, - /// `None` is returned and the slice is not modified. + /// Returns `None` and does not modify the slice if the given + /// range is out of bounds. /// /// # Examples /// @@ -3140,10 +3141,11 @@ impl [T] { } } - /// Removes and returns the portion of the mutable slice specified by `range`. + /// Returns the mutable subslice corresponding to the given range, + /// and modifies the slice to no longer include this subslice. /// - /// If the provided `range` starts or ends outside of the slice, - /// `None` is returned and the slice is not modified. + /// Returns `None` and does not modify the slice if the given + /// range is out of bounds. /// /// # Examples /// @@ -3205,9 +3207,8 @@ impl [T] { } } - /// Takes the first element out of the slice. - /// - /// Returns a reference pointing to the first element of the old slice. + /// Returns a reference to the first element of the slice, + /// and modifies the slice to no longer include this element. /// /// Returns `None` if the slice is empty. /// @@ -3228,9 +3229,8 @@ impl [T] { self.take(..=0).map(|res| &res[0]) } - /// Takes the first element out of the mutable slice. - /// - /// Returns a mutable reference pointing to the first element of the old slice. + /// Returns a mutable reference to the first element of the slice, + /// and modifies the slice to no longer include this element. /// /// Returns `None` if the slice is empty. /// @@ -3252,9 +3252,8 @@ impl [T] { self.take_mut(..=0).map(|res| &mut res[0]) } - /// Takes the last element out of the slice. - /// - /// Returns a reference pointing to the last element of the old slice. + /// Returns a reference to the last element of the slice, + /// and modifies the slice to no longer include this element. /// /// Returns `None` if the slice is empty. /// @@ -3275,9 +3274,8 @@ impl [T] { self.take((self.len() - 1)..).map(|res| &res[0]) } - /// Takes the last element out of the mutable slice. - /// - /// Returns a mutable reference pointing to the last element of the old slice. + /// Returns a mutable reference to the last element of the slice, + /// and modifies the slice to no longer include this element. /// /// Returns `None` if the slice is empty. ///