2012-08-15 20:46:55 -05:00
|
|
|
struct r {
|
2012-09-06 21:40:15 -05:00
|
|
|
i: @mut int,
|
2012-11-14 00:22:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl r : Drop {
|
2012-11-28 17:42:16 -06:00
|
|
|
fn finalize(&self) {
|
2012-11-14 00:22:37 -06:00
|
|
|
*(self.i) += 1;
|
|
|
|
}
|
2012-05-15 22:33:59 -05:00
|
|
|
}
|
2011-09-28 00:40:15 -05:00
|
|
|
|
2012-09-05 17:58:43 -05:00
|
|
|
fn r(i: @mut int) -> r {
|
|
|
|
r {
|
|
|
|
i: i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 00:40:15 -05:00
|
|
|
fn main() {
|
2012-03-26 20:35:18 -05:00
|
|
|
let i = @mut 0;
|
2011-11-18 09:15:46 -06:00
|
|
|
// 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;
|
2011-12-22 19:53:53 -06:00
|
|
|
log(debug, c);
|
2011-11-18 09:15:46 -06:00
|
|
|
}
|
|
|
|
assert *i == 1;
|
|
|
|
}
|