daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(Debug)]
  2. struct Fubar {
  3.   x: Option<i32>,
  4.   y: i32
  5. }
  6.  
  7. impl Fubar {
  8.   fn foo(&mut self) {
  9.     for val in self.x {
  10.         self.bar(val)
  11.     }
  12.   }
  13.   fn bar(&mut self, n: i32) {
  14.     self.y += n;
  15.   }
  16. }
  17.  
  18. fn main() {
  19.     let mut fubar = Fubar { x: Some(1), y: 0, };
  20.     fubar.foo();
  21.     println!("{:?}", fubar)
  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