Skip to content

Instantly share code, notes, and snippets.

@loloof64
Created January 8, 2022 14:22
Show Gist options
  • Save loloof64/f0211b9a22481ba234c76bcc56a5f14f to your computer and use it in GitHub Desktop.
Save loloof64/f0211b9a22481ba234c76bcc56a5f14f to your computer and use it in GitHub Desktop.
[Rust][SmartPointer]A very simple RefCell use case
use std::cell::RefCell;
fn main() {
let x = RefCell::new(42);
{
let mut y = x.borrow_mut();
*y += 60;
}
println!("{:?}", x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment