rust/src/test/run-pass/borrowck-univariant-enum.rs

19 lines
288 B
Rust
Raw Normal View History

enum newtype {
newtype(int)
}
fn main() {
// Test that borrowck treats enums with a single variant
// specially.
let x = @mut 5;
let y = @mut newtype(3);
let z = alt *y {
2012-08-03 21:59:04 -05:00
newtype(b) => {
*x += 1;
*x * b
}
};
assert z == 18;
}