Created
May 26, 2013 12:28
-
-
Save MaikKlein/5652654 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Number{ | |
mut i: int | |
} | |
impl Number { | |
fn mult(&mut self) -> &mut Number{ | |
self.i *= 2; | |
self | |
} | |
} | |
fn main() { | |
let mut test = Number {i: 1}; | |
} | |
/home/maik/hello.rs:19:8: 20:5 error: mismatched types: expected `&mut Number` but found `&mut Number` (lifetime mismatch) | |
/home/maik/hello.rs:19 self | |
/home/maik/hello.rs:20 } | |
/home/maik/hello.rs:17:37: 20:5 note: the anonymous lifetime #2 defined on the block at 17:37... | |
/home/maik/hello.rs:17 fn mult(&mut self) -> &mut Number{ | |
/home/maik/hello.rs:18 self.i *= 2; | |
/home/maik/hello.rs:19 self | |
/home/maik/hello.rs:20 } | |
/home/maik/hello.rs:17:37: 20:5 note: ...does not necessarily outlive the anonymous lifetime #1 defined on the block at 17:37 | |
/home/maik/hello.rs:17 fn mult(&mut self) -> &mut Number{ | |
/home/maik/hello.rs:18 self.i *= 2; | |
/home/maik/hello.rs:19 self | |
/home/maik/hello.rs:20 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment