SHARE
TWEET

Untitled

a guest Sep 15th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Node<'r> {
  2.     update: Box<dyn 'r+FnMut()>,
  3.     deps: Vec<Node<'r>>
  4. }
  5.  
  6. fn main() {
  7.     let mut a = 1;
  8.     let mut b = 1;
  9.     {
  10.     let mut n2 = Node { update: Box::new(|| { b = 3 }), deps: vec![] };
  11.     let mut n = Node {
  12.         update: Box::new(|| {
  13.             a = 2;
  14.         }),
  15.         deps: vec![n2]
  16.     };
  17.     (n.update)();
  18.     for n2 in &mut n.deps {
  19.         (n2.update)();
  20.     }
  21.     }
  22.     println!("Hello, world! {} {}", a, b);
  23. }
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