File tree 2 files changed +8
-0
lines changed
2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ fn test_weak_count() {
103
103
let w = Rc :: downgrade ( & a) ;
104
104
assert ! ( Rc :: strong_count( & a) == 1 ) ;
105
105
assert ! ( Rc :: weak_count( & a) == 1 ) ;
106
+ let r = Rc :: as_weak ( & a) ;
107
+ assert ! ( Rc :: strong_count( & a) == 1 ) ;
108
+ assert ! ( Rc :: weak_count( & a) == 1 ) ;
109
+ assert ! ( r. as_ptr( ) == Rc :: as_ptr( & a) ) ;
106
110
drop ( w) ;
107
111
assert ! ( Rc :: strong_count( & a) == 1 ) ;
108
112
assert ! ( Rc :: weak_count( & a) == 0 ) ;
Original file line number Diff line number Diff line change @@ -314,6 +314,10 @@ fn test_weak_count() {
314
314
let w = Arc :: downgrade ( & a) ;
315
315
assert ! ( Arc :: strong_count( & a) == 1 ) ;
316
316
assert ! ( Arc :: weak_count( & a) == 1 ) ;
317
+ let r = Arc :: as_weak ( & a) ;
318
+ assert ! ( Arc :: strong_count( & a) == 1 ) ;
319
+ assert ! ( Arc :: weak_count( & a) == 1 ) ;
320
+ assert ! ( r. as_ptr( ) == Arc :: as_ptr( & a) ) ;
317
321
let x = w. clone ( ) ;
318
322
assert ! ( Arc :: weak_count( & a) == 2 ) ;
319
323
drop ( w) ;
You can’t perform that action at this time.
0 commit comments