diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-27 18:04:07 -0500 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-27 18:04:07 -0500 |
| commit | 472f99c8011b8de3f796c1ddc5d8f50164a34940 (patch) | |
| tree | 49b14da76ada52943ce4fd147c2aa3fe50d05d1a /rustlings/exercises/19_smart_pointers/rc1.rs | |
| parent | 67fb6c0eb507965836201551f90c7d637bf6cee0 (diff) | |
rustlings: complete 19
Diffstat (limited to 'rustlings/exercises/19_smart_pointers/rc1.rs')
| -rw-r--r-- | rustlings/exercises/19_smart_pointers/rc1.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/rustlings/exercises/19_smart_pointers/rc1.rs b/rustlings/exercises/19_smart_pointers/rc1.rs index ecd3438..5c9ce84 100644 --- a/rustlings/exercises/19_smart_pointers/rc1.rs +++ b/rustlings/exercises/19_smart_pointers/rc1.rs @@ -60,17 +60,17 @@ mod tests { jupiter.details(); // TODO - let saturn = Planet::Saturn(Rc::new(Sun)); + let saturn = Planet::Saturn(Rc::clone(&sun)); println!("reference count = {}", Rc::strong_count(&sun)); // 7 references saturn.details(); // TODO - let uranus = Planet::Uranus(Rc::new(Sun)); + let uranus = Planet::Uranus(Rc::clone(&sun)); println!("reference count = {}", Rc::strong_count(&sun)); // 8 references uranus.details(); // TODO - let neptune = Planet::Neptune(Rc::new(Sun)); + let neptune = Planet::Neptune(Rc::clone(&sun)); println!("reference count = {}", Rc::strong_count(&sun)); // 9 references neptune.details(); @@ -92,12 +92,15 @@ mod tests { println!("reference count = {}", Rc::strong_count(&sun)); // 4 references // TODO + drop(earth); println!("reference count = {}", Rc::strong_count(&sun)); // 3 references // TODO + drop(venus); println!("reference count = {}", Rc::strong_count(&sun)); // 2 references // TODO + drop(mercury); println!("reference count = {}", Rc::strong_count(&sun)); // 1 reference assert_eq!(Rc::strong_count(&sun), 1); |