@@ -146,6 +146,9 @@ impl<T> [T] {
146
146
/// ```
147
147
/// let a = [1, 2, 3];
148
148
/// assert!(!a.is_empty());
149
+ ///
150
+ /// let b: &[i32] = &[];
151
+ /// assert!(b.is_empty());
149
152
/// ```
150
153
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
151
154
#[ rustc_const_stable( feature = "const_slice_is_empty" , since = "1.39.0" ) ]
@@ -185,6 +188,9 @@ impl<T> [T] {
185
188
/// *first = 5;
186
189
/// }
187
190
/// assert_eq!(x, &[5, 1, 2]);
191
+ ///
192
+ /// let y: &mut [i32] = &mut [];
193
+ /// assert_eq!(None, y.first_mut());
188
194
/// ```
189
195
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
190
196
#[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
@@ -297,7 +303,7 @@ impl<T> [T] {
297
303
if let [ .., last] = self { Some ( last) } else { None }
298
304
}
299
305
300
- /// Returns a mutable reference to the last item in the slice.
306
+ /// Returns a mutable reference to the last item in the slice, or `None` if it is empty .
301
307
///
302
308
/// # Examples
303
309
///
@@ -308,6 +314,9 @@ impl<T> [T] {
308
314
/// *last = 10;
309
315
/// }
310
316
/// assert_eq!(x, &[0, 1, 10]);
317
+ ///
318
+ /// let y: &mut [i32] = &mut [];
319
+ /// assert_eq!(None, y.last_mut());
311
320
/// ```
312
321
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
313
322
#[ rustc_const_unstable( feature = "const_slice_first_last" , issue = "83570" ) ]
0 commit comments