SHARE
TWEET

Untitled

a guest Sep 16th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::sync::{Arc, Mutex};
  2.  
  3. #[derive(Debug)]
  4. struct Foo(Arc<Mutex<usize>>);
  5.  
  6. impl Foo {
  7.     fn mutate(&self) {
  8.         let mut current = self.0.lock().unwrap();
  9.         *current = 1;
  10.     }
  11. }
  12.  
  13. fn main() {
  14.     let foo = Foo(Arc::new(Mutex::new(0)));
  15.     println!("{:?}", foo);
  16.     foo.mutate();
  17.     println!("{:?}", foo);
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top