blob: 67251ca6aa9ba2dae2f613b978350a7eae3c22dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
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)
}
|