Guest User

Untitled

a guest
Dec 11th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. struct Thing {
  2. a: u8
  3. }
  4.  
  5. struct ClosureHolder {
  6. closure: Option<Box<FnMut()>>
  7. }
  8.  
  9. fn main()
  10. {
  11.  
  12. let mut thing = Thing{a: 0};
  13.  
  14. let mut closure_holder = ClosureHolder{closure: None};
  15.  
  16. closure_holder.closure = Some(Box::new(move || { thing.a = 1 }));
  17.  
  18. }
Add Comment
Please, Sign In to add comment