diff options
Diffstat (limited to 'users/wpcarro/scratch/rust/src/rc/mod.rs')
-rw-r--r-- | users/wpcarro/scratch/rust/src/rc/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/users/wpcarro/scratch/rust/src/rc/mod.rs b/users/wpcarro/scratch/rust/src/rc/mod.rs new file mode 100644 index 000000000000..67251ca6aa9b --- /dev/null +++ b/users/wpcarro/scratch/rust/src/rc/mod.rs @@ -0,0 +1,12 @@ +// Playing around with Rust's "smart pointers". Starting off with a wrapper type +// that allows multiple readers (owners?) of some data. + +use std::rc::Rc; + +pub fn example() { + let five = Rc::new(5); + let x = Rc::clone(&five); + let y = Rc::clone(&five); + let z = Rc::clone(&five); + println!("result: {}", *x + *y + *z) +} |