Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct Fubar {
- x: Option<i32>,
- y: i32
- }
- impl Fubar {
- fn foo(&mut self) {
- for val in self.x {
- self.bar(val)
- }
- }
- fn bar(&mut self, n: i32) {
- self.y += n;
- }
- }
- fn main() {
- let mut fubar = Fubar { x: Some(1), y: 0, };
- fubar.foo();
- println!("{:?}", fubar)
- }
Add Comment
Please, Sign In to add comment