File tree 3 files changed +18
-18
lines changed
3 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -276,9 +276,6 @@ use crate::string::String;
276
276
#[ cfg( not( no_global_oom_handling) ) ]
277
277
use crate :: vec:: Vec ;
278
278
279
- #[ cfg( test) ]
280
- mod tests;
281
-
282
279
// This is repr(C) to future-proof against possible field-reordering, which
283
280
// would interfere with otherwise safe [into|from]_raw() of transmutable
284
281
// inner types.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -315,6 +315,24 @@ fn weak_self_cyclic() {
315
315
// hopefully we don't double-free (or leak)...
316
316
}
317
317
318
+ #[ test]
319
+ fn is_unique ( ) {
320
+ fn is_unique < T > ( this : & Rc < T > ) -> bool {
321
+ Rc :: weak_count ( this) == 0 && Rc :: strong_count ( this) == 1
322
+ }
323
+
324
+ let x = Rc :: new ( 3 ) ;
325
+ assert ! ( is_unique( & x) ) ;
326
+ let y = x. clone ( ) ;
327
+ assert ! ( !is_unique( & x) ) ;
328
+ drop ( y) ;
329
+ assert ! ( is_unique( & x) ) ;
330
+ let w = Rc :: downgrade ( & x) ;
331
+ assert ! ( !is_unique( & x) ) ;
332
+ drop ( w) ;
333
+ assert ! ( is_unique( & x) ) ;
334
+ }
335
+
318
336
#[ test]
319
337
fn test_strong_count ( ) {
320
338
let a = Rc :: new ( 0 ) ;
You can’t perform that action at this time.
0 commit comments