]>
git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch15-smart-pointers/listing-15-19/src/main.rs
6 use crate::List
::{Cons, Nil}
;
11 let a
= Rc
::new(Cons(5, Rc
::new(Cons(10, Rc
::new(Nil
)))));
12 println
!("count after creating a = {}", Rc
::strong_count(&a
));
13 let b
= Cons(3, Rc
::clone(&a
));
14 println
!("count after creating b = {}", Rc
::strong_count(&a
));
16 let c
= Cons(4, Rc
::clone(&a
));
17 println
!("count after creating c = {}", Rc
::strong_count(&a
));
19 println
!("count after c goes out of scope = {}", Rc
::strong_count(&a
));