@@ -2209,6 +2209,49 @@ impl<T> *mut [T] {
22092209 }
22102210}
22112211
2212+ impl < T , const N : usize > * mut [ T ; N ] {
2213+ /// Returns a raw pointer to the array's buffer.
2214+ ///
2215+ /// This is equivalent to casting `self` to `*mut T`, but more type-safe.
2216+ ///
2217+ /// # Examples
2218+ ///
2219+ /// ```rust
2220+ /// #![feature(array_ptr_get)]
2221+ /// use std::ptr;
2222+ ///
2223+ /// let arr: *mut [i8; 3] = ptr::null_mut();
2224+ /// assert_eq!(arr.as_mut_ptr(), ptr::null_mut());
2225+ /// ```
2226+ #[ inline]
2227+ #[ unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2228+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2229+ pub const fn as_mut_ptr ( self ) -> * mut T {
2230+ self as * mut T
2231+ }
2232+
2233+ /// Returns a raw pointer to a mutable slice containing the entire array.
2234+ ///
2235+ /// # Examples
2236+ ///
2237+ /// ```
2238+ /// #![feature(array_ptr_get)]
2239+ ///
2240+ /// let mut arr = [1, 2, 5];
2241+ /// let ptr: *mut [i32; 3] = &mut arr;
2242+ /// unsafe {
2243+ /// (&mut *ptr.as_mut_slice())[..2].copy_from_slice(&[3, 4]);
2244+ /// }
2245+ /// assert_eq!(arr, [3, 4, 5]);
2246+ /// ```
2247+ #[ inline]
2248+ #[ unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2249+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2250+ pub const fn as_mut_slice ( self ) -> * mut [ T ] {
2251+ slice_from_raw_parts_mut ( self . as_mut_ptr ( ) , N )
2252+ }
2253+ }
2254+
22122255// Equality for pointers
22132256#[ stable( feature = "rust1" , since = "1.0.0" ) ]
22142257impl < T : ?Sized > PartialEq for * mut T {
0 commit comments