rust/tests/ui/mut/mutable-class-fields-2.rs

25 lines
316 B
Rust
Raw Normal View History

struct Cat {
meows : usize,
how_hungry : isize,
}
impl Cat {
pub fn eat(&self) {
2013-03-15 19:24:24 +00:00
self.how_hungry -= 5; //~ ERROR cannot assign
}
2012-09-05 22:58:43 +00:00
}
fn cat(in_x : usize, in_y : isize) -> Cat {
Cat {
2012-09-05 22:58:43 +00:00
meows: in_x,
how_hungry: in_y
}
}
fn main() {
let nyan : Cat = cat(52, 99);
nyan.eat();
}