File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -1644,6 +1644,23 @@ impl<T> *const [T] {
16441644 metadata ( self )
16451645 }
16461646
1647+ /// Returns `true` if the raw slice has a length of 0.
1648+ ///
1649+ /// # Examples
1650+ ///
1651+ /// ```
1652+ /// #![feature(slice_ptr_len)]
1653+ ///
1654+ /// let slice: *const [i8] = ptr::slice_from_raw_parts(ptr::null(), 3);
1655+ /// assert!(!slice.is_empty());
1656+ /// ```
1657+ #[ inline( always) ]
1658+ #[ unstable( feature = "slice_ptr_len" , issue = "71146" ) ]
1659+ #[ rustc_const_unstable( feature = "const_slice_ptr_len" , issue = "71146" ) ]
1660+ pub const fn is_empty ( self ) -> bool {
1661+ self . len ( ) == 0
1662+ }
1663+
16471664 /// Returns a raw pointer to the slice's buffer.
16481665 ///
16491666 /// This is equivalent to casting `self` to `*const T`, but more type-safe.
Original file line number Diff line number Diff line change @@ -1921,9 +1921,8 @@ impl<T> *mut [T] {
19211921 /// ```
19221922 /// #![feature(slice_ptr_len)]
19231923 ///
1924- /// let mut a = [1, 2, 3];
1925- /// let ptr = &mut a as *mut [_];
1926- /// assert!(!ptr.is_empty());
1924+ /// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3);
1925+ /// assert!(!slice.is_empty());
19271926 /// ```
19281927 #[ inline( always) ]
19291928 #[ unstable( feature = "slice_ptr_len" , issue = "71146" ) ]
You can’t perform that action at this time.
0 commit comments