rust/src/test/run-pass/resource-assign-is-not-copy.rs

28 lines
402 B
Rust
Raw Normal View History

2012-08-15 20:46:55 -05:00
struct r {
2012-09-06 21:40:15 -05:00
i: @mut int,
}
impl r : Drop {
fn finalize(&self) {
*(self.i) += 1;
}
}
2012-09-05 17:58:43 -05:00
fn r(i: @mut int) -> r {
r {
i: i
}
}
fn main() {
2012-03-26 20:35:18 -05:00
let i = @mut 0;
// Even though these look like copies, they are guaranteed not to be
{
let a = r(i);
2012-09-19 00:45:24 -05:00
let b = (move a, 10);
let (c, _d) = move b;
log(debug, c);
}
assert *i == 1;
}