File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1575,6 +1575,27 @@ impl<T> NonNull<[T]> {
15751575 self . as_ptr ( ) . len ( )
15761576 }
15771577
1578+ /// Returns `true` if the non-null raw slice has a length of 0.
1579+ ///
1580+ /// # Examples
1581+ ///
1582+ /// ```rust
1583+ /// use std::ptr::NonNull;
1584+ ///
1585+ /// let slice: NonNull<[i8]> = NonNull::slice_from_raw_parts(NonNull::dangling(), 3);
1586+ /// assert_eq!(!slice.is_empty());
1587+ /// ```
1588+ #[ stable( feature = "slice_ptr_is_empty_nonnull" , since = "CURRENT_RUSTC_VERSION" ) ]
1589+ #[ rustc_const_stable(
1590+ feature = "const_slice_ptr_is_empty_nonnull" ,
1591+ since = "CURRENT_RUSTC_VERSION"
1592+ ) ]
1593+ #[ must_use]
1594+ #[ inline]
1595+ pub const fn is_empty ( self ) -> bool {
1596+ self . len ( ) == 0
1597+ }
1598+
15781599 /// Returns a non-null pointer to the slice's buffer.
15791600 ///
15801601 /// # Examples
You can’t perform that action at this time.
0 commit comments