SHARE
TWEET

Untitled

a guest Jun 15th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct Bar {
  2.     c: usize
  3. }
  4.  
  5. impl Bar {
  6.     fn add(&mut self) {
  7.         self.c += 1;
  8.     }
  9. }
  10.  
  11. fn test(bar: Option<&mut Bar>) {
  12.     for _ in 0..10 {
  13.         if let Some(b) = bar {
  14.             b.add();
  15.         }
  16.     }
  17. }
  18.  
  19. fn main() {
  20.     let mut bar = Bar{c: 0};
  21.     test(Some(&mut bar));
  22. }
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