Skip to content

Instantly share code, notes, and snippets.

@xymostech
Last active December 18, 2015 22:39
Show Gist options
  • Save xymostech/5856233 to your computer and use it in GitHub Desktop.
Save xymostech/5856233 to your computer and use it in GitHub Desktop.
fn tupleize(num: ~int) -> (~int,) {
(num,)
}
fn main() {
let mut num = ~1;
loop {
(num,) = tupleize(num);
}
}
fn identity(num: ~int) -> ~int {
num
}
fn main() {
let mut num = ~1;
loop {
num = identity(num);
}
}
$ 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