File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1547,6 +1547,15 @@ impl<T> *const [T] {
15471547 }
15481548}
15491549
1550+ impl < T > * const T {
1551+ /// Casts from a pointer-to-`T` to a pointer-to-`[T; N]`.
1552+ #[ inline]
1553+ #[ unstable( feature = "ptr_cast_array" , issue = "144514" ) ]
1554+ pub const fn cast_array < const N : usize > ( self ) -> * const [ T ; N ] {
1555+ self . cast ( )
1556+ }
1557+ }
1558+
15501559impl < T , const N : usize > * const [ T ; N ] {
15511560 /// Returns a raw pointer to the array's buffer.
15521561 ///
Original file line number Diff line number Diff line change @@ -1965,6 +1965,15 @@ impl<T> *mut [T] {
19651965 }
19661966}
19671967
1968+ impl < T > * mut T {
1969+ /// Casts from a pointer-to-`T` to a pointer-to-`[T; N]`.
1970+ #[ inline]
1971+ #[ unstable( feature = "ptr_cast_array" , issue = "144514" ) ]
1972+ pub const fn cast_array < const N : usize > ( self ) -> * mut [ T ; N ] {
1973+ self . cast ( )
1974+ }
1975+ }
1976+
19681977impl < T , const N : usize > * mut [ T ; N ] {
19691978 /// Returns a raw pointer to the array's buffer.
19701979 ///
Original file line number Diff line number Diff line change @@ -193,6 +193,13 @@ impl<T: Sized> NonNull<T> {
193193 // requirements for a reference.
194194 unsafe { & mut * self . cast ( ) . as_ptr ( ) }
195195 }
196+
197+ /// Casts from a pointer-to-`T` to a pointer-to-`[T; N]`.
198+ #[ inline]
199+ #[ unstable( feature = "ptr_cast_array" , issue = "144514" ) ]
200+ pub const fn cast_array < const N : usize > ( self ) -> NonNull < [ T ; N ] > {
201+ self . cast ( )
202+ }
196203}
197204
198205impl < T : PointeeSized > NonNull < T > {
You can’t perform that action at this time.
0 commit comments