File tree 4 files changed +26
-0
lines changed
4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1179,6 +1179,14 @@ impl<T> From<Vec<T>> for Rc<[T]> {
1179
1179
}
1180
1180
}
1181
1181
1182
+ #[ unstable( feature = "rc_into_nonnull" , reason = "newly added" , issue = "0" ) ]
1183
+ impl < T : ?Sized > Into < NonNull < T > > for Rc < T > {
1184
+ #[ inline]
1185
+ fn into ( self ) -> NonNull < T > {
1186
+ unsafe { NonNull :: new_unchecked ( Rc :: into_raw ( self ) as * mut _ ) }
1187
+ }
1188
+ }
1189
+
1182
1190
/// `Weak` is a version of [`Rc`] that holds a non-owning reference to the
1183
1191
/// managed value. The value is accessed by calling [`upgrade`] on the `Weak`
1184
1192
/// pointer, which returns an [`Option`]`<`[`Rc`]`<T>>`.
Original file line number Diff line number Diff line change @@ -1574,6 +1574,14 @@ impl<T> From<Vec<T>> for Arc<[T]> {
1574
1574
}
1575
1575
}
1576
1576
1577
+ #[ unstable( feature = "arc_into_nonnull" , reason = "newly added" , issue = "0" ) ]
1578
+ impl < T : ?Sized > Into < NonNull < T > > for Arc < T > {
1579
+ #[ inline]
1580
+ fn into ( self ) -> NonNull < T > {
1581
+ unsafe { NonNull :: new_unchecked ( Arc :: into_raw ( self ) as * mut _ ) }
1582
+ }
1583
+ }
1584
+
1577
1585
#[ cfg( test) ]
1578
1586
mod tests {
1579
1587
use std:: boxed:: Box ;
Original file line number Diff line number Diff line change @@ -95,3 +95,8 @@ fn eq() {
95
95
assert ! ( !( x != x) ) ;
96
96
assert_eq ! ( * x. 0 . borrow( ) , 0 ) ;
97
97
}
98
+
99
+ #[ test]
100
+ fn to_nonnull ( ) {
101
+ let _: std:: ptr:: NonNull < i32 > = Arc :: new ( 0 ) . into ( ) ;
102
+ }
Original file line number Diff line number Diff line change @@ -95,3 +95,8 @@ fn eq() {
95
95
assert ! ( !( x != x) ) ;
96
96
assert_eq ! ( * x. 0 . borrow( ) , 0 ) ;
97
97
}
98
+
99
+ #[ test]
100
+ fn to_nonnull ( ) {
101
+ let _: std:: ptr:: NonNull < i32 > = Rc :: new ( 0 ) . into ( ) ;
102
+ }
You can’t perform that action at this time.
0 commit comments