File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,24 @@ impl<T> NonNull<[T]> {
224224 unsafe { NonNull :: new_unchecked ( self . as_ptr ( ) . as_mut_ptr ( ) ) }
225225 }
226226
227+ /// Returns a raw pointer to the slice's buffer.
228+ ///
229+ /// # Examples
230+ ///
231+ /// ```rust
232+ /// #![feature(slice_ptr_get, nonnull_slice_from_raw_parts)]
233+ /// use std::ptr::NonNull;
234+ ///
235+ /// let slice: NonNull<[i8]> = NonNull::slice_from_raw_parts(NonNull::dangling(), 3);
236+ /// assert_eq!(slice.as_mut_ptr(), 1 as *mut i8);
237+ /// ```
238+ #[ inline]
239+ #[ unstable( feature = "slice_ptr_get" , issue = "74265" ) ]
240+ #[ rustc_const_unstable( feature = "slice_ptr_get" , issue = "74265" ) ]
241+ pub const fn as_mut_ptr ( self ) -> * mut T {
242+ self . as_non_null_ptr ( ) . as_ptr ( )
243+ }
244+
227245 /// Returns a raw pointer to an element or subslice, without doing bounds
228246 /// checking.
229247 ///
You can’t perform that action at this time.
0 commit comments