Last active
December 18, 2015 22:39
-
-
Save xymostech/5856233 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
fn tupleize(num: ~int) -> (~int,) { | |
(num,) | |
} | |
fn main() { | |
let mut num = ~1; | |
loop { | |
(num,) = tupleize(num); | |
} | |
} |
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
fn identity(num: ~int) -> ~int { | |
num | |
} | |
fn main() { | |
let mut num = ~1; | |
loop { | |
num = identity(num); | |
} | |
} |
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
$ rustc bad.rs | |
loop.rs:9:26: 9:29 error: use of moved value: `num` | |
loop.rs:9 (num,) = tupleize(num); | |
^~~ | |
loop.rs:9:26: 9:29 note: `num` moved here because it has type `~int`, which is moved by default (use `copy` to override) | |
loop.rs:9 (num,) = tupleize(num); | |
^~~ | |
loop.rs:9:9: 9:12 error: use of moved value: `num` | |
loop.rs:9 (num,) = tupleize(num); | |
^~~ | |
loop.rs:9:26: 9:29 note: `num` moved here because it has type `~int`, which is moved by default (use `copy` to override) | |
loop.rs:9 (num,) = tupleize(num); | |
^~~ | |
$ rustc good.rs | |
(nothing) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment