File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,15 @@ impl From<Box<str>> for Box<[u8]> {
479
479
}
480
480
}
481
481
482
+ #[ allow( incoherent_fundamental_impls) ]
483
+ #[ unstable( feature = "box_into_raw_non_null" , issue = "47336" ) ]
484
+ impl < T : ?Sized > Into < NonNull < T > > for Box < T > {
485
+ #[ inline]
486
+ fn into ( self ) -> NonNull < T > {
487
+ Box :: into_unique ( self ) . into ( )
488
+ }
489
+ }
490
+
482
491
impl Box < dyn Any > {
483
492
#[ inline]
484
493
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -148,3 +148,11 @@ fn boxed_slice_from_iter() {
148
148
assert_eq ! ( boxed. len( ) , 100 ) ;
149
149
assert_eq ! ( boxed[ 7 ] , 7 ) ;
150
150
}
151
+
152
+ #[ test]
153
+ fn to_nonnull ( ) {
154
+ let boxed: Box < i32 > = Box :: from ( 0 ) ;
155
+ let ptr: std:: ptr:: NonNull < i32 > = boxed. into ( ) ;
156
+ let deref = unsafe { * ptr. as_ref ( ) } ;
157
+ assert_eq ! ( deref, 0 ) ;
158
+ }
You can’t perform that action at this time.
0 commit comments