File tree 1 file changed +18
-0
lines changed
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]> {
224
224
unsafe { NonNull :: new_unchecked ( self . as_ptr ( ) . as_mut_ptr ( ) ) }
225
225
}
226
226
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
+
227
245
/// Returns a raw pointer to an element or subslice, without doing bounds
228
246
/// checking.
229
247
///
You can’t perform that action at this time.
0 commit comments