blob: 67251ca6aa9ba2dae2f613b978350a7eae3c22dd (
plain) (
tree)
|
|
// 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)
}
|