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] {
1547
1547
}
1548
1548
}
1549
1549
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
+
1550
1559
impl < T , const N : usize > * const [ T ; N ] {
1551
1560
/// Returns a raw pointer to the array's buffer.
1552
1561
///
Original file line number Diff line number Diff line change @@ -1965,6 +1965,15 @@ impl<T> *mut [T] {
1965
1965
}
1966
1966
}
1967
1967
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
+
1968
1977
impl < T , const N : usize > * mut [ T ; N ] {
1969
1978
/// Returns a raw pointer to the array's buffer.
1970
1979
///
Original file line number Diff line number Diff line change @@ -193,6 +193,13 @@ impl<T: Sized> NonNull<T> {
193
193
// requirements for a reference.
194
194
unsafe { & mut * self . cast ( ) . as_ptr ( ) }
195
195
}
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
+ }
196
203
}
197
204
198
205
impl < T : PointeeSized > NonNull < T > {
You can’t perform that action at this time.
0 commit comments