@@ -2195,6 +2195,49 @@ impl<T> *mut [T] {
21952195 }
21962196}
21972197
2198+ impl < T , const N : usize > * mut [ T ; N ] {
2199+ /// Returns a raw pointer to the array's buffer.
2200+ ///
2201+ /// This is equivalent to casting `self` to `*mut T`, but more type-safe.
2202+ ///
2203+ /// # Examples
2204+ ///
2205+ /// ```rust
2206+ /// #![feature(array_ptr_get)]
2207+ /// use std::ptr;
2208+ ///
2209+ /// let arr: *mut [i8; 3] = ptr::null_mut();
2210+ /// assert_eq!(arr.as_mut_ptr(), ptr::null_mut());
2211+ /// ```
2212+ #[ inline]
2213+ #[ unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2214+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2215+ pub const fn as_mut_ptr ( self ) -> * mut T {
2216+ self as * mut T
2217+ }
2218+
2219+ /// Returns a raw pointer to a mutable slice containing the entire array.
2220+ ///
2221+ /// # Examples
2222+ ///
2223+ /// ```
2224+ /// #![feature(array_ptr_get)]
2225+ ///
2226+ /// let mut arr = [1, 2, 5];
2227+ /// let ptr: *mut [i32; 3] = &mut arr;
2228+ /// unsafe {
2229+ /// (&mut *ptr.as_mut_slice())[..2].copy_from_slice(&[3, 4]);
2230+ /// }
2231+ /// assert_eq!(arr, [3, 4, 5]);
2232+ /// ```
2233+ #[ inline]
2234+ #[ unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2235+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119834" ) ]
2236+ pub const fn as_mut_slice ( self ) -> * mut [ T ] {
2237+ slice_from_raw_parts_mut ( self . as_mut_ptr ( ) , N )
2238+ }
2239+ }
2240+
21982241// Equality for pointers
21992242#[ stable( feature = "rust1" , since = "1.0.0" ) ]
22002243impl < T : ?Sized > PartialEq for * mut T {
0 commit comments