@@ -1768,6 +1768,47 @@ impl<T> *const [T] {
17681768 }
17691769}
17701770
1771+ impl < T , const N : usize > * const [ T ; N ] {
1772+ /// Returns a raw pointer to the array's buffer.
1773+ ///
1774+ /// This is equivalent to casting `self` to `*const T`, but more type-safe.
1775+ ///
1776+ /// # Examples
1777+ ///
1778+ /// ```rust
1779+ /// #![feature(array_ptr_get)]
1780+ /// use std::ptr;
1781+ ///
1782+ /// let arr: *const [i8; 3] = ptr::null();
1783+ /// assert_eq!(arr.as_ptr(), ptr::null());
1784+ /// ```
1785+ #[ inline]
1786+ #[ unstable( feature = "array_ptr_get" , issue = "119411" ) ]
1787+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119411" ) ]
1788+ pub const fn as_ptr ( self ) -> * const T {
1789+ self as * const T
1790+ }
1791+
1792+ /// Returns a raw pointer to a shared slice containing the entire array.
1793+ ///
1794+ /// # Examples
1795+ ///
1796+ /// ```
1797+ /// #![feature(array_ptr_get, slice_ptr_len)]
1798+ ///
1799+ /// let arr: *const [i32; 3] = &[1, 2, 4] as *const [i32; 3];
1800+ /// let slice: *const [i32] = arr.as_slice();
1801+ /// assert_eq!(slice.len(), 3);
1802+ /// ```
1803+ #[ inline]
1804+ #[ unstable( feature = "array_ptr_get" , issue = "119411" ) ]
1805+ #[ rustc_const_unstable( feature = "array_ptr_get" , issue = "119411" ) ]
1806+ pub const fn as_slice ( self ) -> * const [ T ] {
1807+ // SAFETY: `N` is the length of the array, so the pointer is always in-bounds.
1808+ unsafe { slice:: from_raw_parts ( self . as_ptr ( ) , N ) }
1809+ }
1810+ }
1811+
17711812// Equality for pointers
17721813#[ stable( feature = "rust1" , since = "1.0.0" ) ]
17731814impl < T : ?Sized > PartialEq for * const T {
0 commit comments