Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::sync::{Arc, Mutex};
- #[derive(Debug)]
- struct Foo(Arc<Mutex<usize>>);
- impl Foo {
- fn mutate(&self) {
- let mut current = self.0.lock().unwrap();
- *current = 1;
- }
- }
- fn main() {
- let foo = Foo(Arc::new(Mutex::new(0)));
- println!("{:?}", foo);
- foo.mutate();
- println!("{:?}", foo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement