Skip to content

Commit

Permalink
Added a "main" function to the example so it can be run and fiddled w…
Browse files Browse the repository at this point in the history
…ith.
  • Loading branch information
raslanove committed Nov 15, 2018
1 parent 4db2381 commit cfdf830
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions data types.md
Expand Up @@ -340,6 +340,14 @@ fn foo(x: Rc<RefCell<S>>) {
// println!("The field {}", x.borrow().field); // Error - can't mut and immut borrow
println!("The field {}", s.field);
}

fn main() {
let s = S{field:12};
let x: Rc<RefCell<S>> = Rc::new(RefCell::new(s));
foo(x.clone());

println!("The field {}", x.borrow().field);
}
```

If you're using Cell/RefCell, you should try to put them on the smallest object
Expand Down

0 comments on commit cfdf830

Please sign in to comment.