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

19 lines
290 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);
2012-08-06 14:34:08 -05:00
let z = match *y {
2012-08-03 21:59:04 -05:00
newtype(b) => {
*x += 1;
*x * b
}
};
assert z == 18;
}