File tree 4 files changed +6
-50
lines changed
4 files changed +6
-50
lines changed Original file line number Diff line number Diff line change @@ -1749,7 +1749,7 @@ struct WeakInner<'a> {
1749
1749
strong : & ' a Cell < usize > ,
1750
1750
}
1751
1751
1752
- impl < T : ? Sized > Weak < T > {
1752
+ impl < T > Weak < T > {
1753
1753
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
1754
1754
///
1755
1755
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -1882,7 +1882,9 @@ impl<T: ?Sized> Weak<T> {
1882
1882
// SAFETY: we now have recovered the original Weak pointer, so can create the Weak.
1883
1883
Weak { ptr : unsafe { NonNull :: new_unchecked ( ptr) } }
1884
1884
}
1885
+ }
1885
1886
1887
+ impl < T : ?Sized > Weak < T > {
1886
1888
/// Attempts to upgrade the `Weak` pointer to an [`Rc`], delaying
1887
1889
/// dropping of the inner value if successful.
1888
1890
///
Original file line number Diff line number Diff line change @@ -208,30 +208,6 @@ fn into_from_weak_raw() {
208
208
}
209
209
}
210
210
211
- #[ test]
212
- fn test_into_from_weak_raw_unsized ( ) {
213
- use std:: fmt:: Display ;
214
- use std:: string:: ToString ;
215
-
216
- let arc: Rc < str > = Rc :: from ( "foo" ) ;
217
- let weak: Weak < str > = Rc :: downgrade ( & arc) ;
218
-
219
- let ptr = Weak :: into_raw ( weak. clone ( ) ) ;
220
- let weak2 = unsafe { Weak :: from_raw ( ptr) } ;
221
-
222
- assert_eq ! ( unsafe { & * ptr } , "foo" ) ;
223
- assert ! ( weak. ptr_eq( & weak2) ) ;
224
-
225
- let arc: Rc < dyn Display > = Rc :: new ( 123 ) ;
226
- let weak: Weak < dyn Display > = Rc :: downgrade ( & arc) ;
227
-
228
- let ptr = Weak :: into_raw ( weak. clone ( ) ) ;
229
- let weak2 = unsafe { Weak :: from_raw ( ptr) } ;
230
-
231
- assert_eq ! ( unsafe { & * ptr } . to_string( ) , "123" ) ;
232
- assert ! ( weak. ptr_eq( & weak2) ) ;
233
- }
234
-
235
211
#[ test]
236
212
fn get_mut ( ) {
237
213
let mut x = Rc :: new ( 3 ) ;
Original file line number Diff line number Diff line change @@ -1535,7 +1535,7 @@ struct WeakInner<'a> {
1535
1535
strong : & ' a atomic:: AtomicUsize ,
1536
1536
}
1537
1537
1538
- impl < T : ? Sized > Weak < T > {
1538
+ impl < T > Weak < T > {
1539
1539
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
1540
1540
///
1541
1541
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -1668,7 +1668,9 @@ impl<T: ?Sized> Weak<T> {
1668
1668
// SAFETY: we now have recovered the original Weak pointer, so can create the Weak.
1669
1669
unsafe { Weak { ptr : NonNull :: new_unchecked ( ptr) } }
1670
1670
}
1671
+ }
1671
1672
1673
+ impl < T : ?Sized > Weak < T > {
1672
1674
/// Attempts to upgrade the `Weak` pointer to an [`Arc`], delaying
1673
1675
/// dropping of the inner value if successful.
1674
1676
///
Original file line number Diff line number Diff line change @@ -158,30 +158,6 @@ fn into_from_weak_raw() {
158
158
}
159
159
}
160
160
161
- #[ test]
162
- fn test_into_from_weak_raw_unsized ( ) {
163
- use std:: fmt:: Display ;
164
- use std:: string:: ToString ;
165
-
166
- let arc: Arc < str > = Arc :: from ( "foo" ) ;
167
- let weak: Weak < str > = Arc :: downgrade ( & arc) ;
168
-
169
- let ptr = Weak :: into_raw ( weak. clone ( ) ) ;
170
- let weak2 = unsafe { Weak :: from_raw ( ptr) } ;
171
-
172
- assert_eq ! ( unsafe { & * ptr } , "foo" ) ;
173
- assert ! ( weak. ptr_eq( & weak2) ) ;
174
-
175
- let arc: Arc < dyn Display > = Arc :: new ( 123 ) ;
176
- let weak: Weak < dyn Display > = Arc :: downgrade ( & arc) ;
177
-
178
- let ptr = Weak :: into_raw ( weak. clone ( ) ) ;
179
- let weak2 = unsafe { Weak :: from_raw ( ptr) } ;
180
-
181
- assert_eq ! ( unsafe { & * ptr } . to_string( ) , "123" ) ;
182
- assert ! ( weak. ptr_eq( & weak2) ) ;
183
- }
184
-
185
161
#[ test]
186
162
fn test_cowarc_clone_make_mut ( ) {
187
163
let mut cow0 = Arc :: new ( 75 ) ;
You can’t perform that action at this time.
0 commit comments