diff --git a/src/smart-pointers/rc.md b/src/smart-pointers/rc.md index 525b3e66..b1f1b654 100644 --- a/src/smart-pointers/rc.md +++ b/src/smart-pointers/rc.md @@ -19,6 +19,22 @@ fn main() { } ``` +Each `Rc` points to the same shared data structure, containing strong and weak +pointers and the value: + +```bob + Stack Heap +.- - - - - - - -. .- - - - - - - - - - - - - - - - -. +: : : : +: +-----+ : : +-----------+-------------+ : +: a: | o---|---:--+--:-->| count: 2 | value: 10 | : +: +-----+ : | : +-----------+-------------+ : +: b: | o---|---:--+ : : +: +-----+ : `- - - - - - - - - - - - - - - - -' +: : +`- - - - - - - -' +``` + - See [`Arc`][2] and [`Mutex`][3] if you are in a multi-threaded context. - You can _downgrade_ a shared pointer into a [`Weak`][4] pointer to create cycles that will get dropped.