()
| 9 | } |
| 10 | |
| 11 | fn main() -> Result<()> { |
| 12 | let a = Box::new(5); |
| 13 | println!("deref of box {:?} yields {}", a, *a); |
| 14 | let mut l = List { |
| 15 | next: None, |
| 16 | value: 1, |
| 17 | }; |
| 18 | l.next = Some(Box::new(List { |
| 19 | next: None, |
| 20 | value: 2, |
| 21 | })); |
| 22 | println!("list value {}", l.value); |
| 23 | |
| 24 | let b = Rc::new(*a); |
| 25 | let _c = Rc::clone(&b); // increase reference count (cheap) |
| 26 | println!("{} refcount: {}", &b, Rc::strong_count(&b)); |
| 27 | // if b is not a Rc type this is potentially deep-copying (expensive) |
| 28 | // avoid this notation when doing refcount clones |
| 29 | let _d = b.clone(); |
| 30 | println!("{} refcount: {}", &b, Rc::strong_count(&b)); |
| 31 | Ok(()) |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected