File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -2112,9 +2112,10 @@ impl<T> Weak<T> {
2112
2112
/// assert!(empty.upgrade().is_none());
2113
2113
/// ```
2114
2114
#[ stable( feature = "downgraded_weak" , since = "1.10.0" ) ]
2115
+ #[ rustc_const_unstable( feature = "const_weak_new" , issue = "95091" , reason = "recently added" ) ]
2115
2116
#[ must_use]
2116
- pub fn new ( ) -> Weak < T > {
2117
- Weak { ptr : NonNull :: new ( usize:: MAX as * mut RcBox < T > ) . expect ( "MAX is not 0" ) }
2117
+ pub const fn new ( ) -> Weak < T > {
2118
+ Weak { ptr : unsafe { NonNull :: new_unchecked ( usize:: MAX as * mut RcBox < T > ) } }
2118
2119
}
2119
2120
}
2120
2121
Original file line number Diff line number Diff line change @@ -1742,9 +1742,10 @@ impl<T> Weak<T> {
1742
1742
/// assert!(empty.upgrade().is_none());
1743
1743
/// ```
1744
1744
#[ stable( feature = "downgraded_weak" , since = "1.10.0" ) ]
1745
+ #[ rustc_const_unstable( feature = "const_weak_new" , issue = "95091" , reason = "recently added" ) ]
1745
1746
#[ must_use]
1746
- pub fn new ( ) -> Weak < T > {
1747
- Weak { ptr : NonNull :: new ( usize:: MAX as * mut ArcInner < T > ) . expect ( "MAX is not 0" ) }
1747
+ pub const fn new ( ) -> Weak < T > {
1748
+ Weak { ptr : unsafe { NonNull :: new_unchecked ( usize:: MAX as * mut ArcInner < T > ) } }
1748
1749
}
1749
1750
}
1750
1751
You can’t perform that action at this time.
0 commit comments