rust/src/test/compile-fail/mutable-class-fields-2.rs

20 lines
310 B
Rust
Raw Normal View History

// error-pattern:assigning to immutable field
2012-08-16 01:46:55 +00:00
struct cat {
priv {
let mut meows : uint;
}
let how_hungry : int;
fn eat() {
self.how_hungry -= 5;
}
new(in_x : uint, in_y : int) { self.meows = in_x; self.how_hungry = in_y; }
}
fn main() {
let nyan : cat = cat(52u, 99);
nyan.eat();
}