2018-12-17 03:21:47 +00:00
|
|
|
struct Cat {
|
2015-01-08 11:02:42 +00:00
|
|
|
meows : usize,
|
2012-03-28 05:08:48 +00:00
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
how_hungry : isize,
|
2012-09-08 02:04:40 +00:00
|
|
|
}
|
2012-03-28 05:08:48 +00:00
|
|
|
|
2018-12-17 03:21:47 +00:00
|
|
|
impl Cat {
|
2013-05-31 22:17:22 +00:00
|
|
|
pub fn eat(&self) {
|
2013-03-15 19:24:24 +00:00
|
|
|
self.how_hungry -= 5; //~ ERROR cannot assign
|
2012-03-28 05:08:48 +00:00
|
|
|
}
|
|
|
|
|
2012-09-05 22:58:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-17 03:21:47 +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
|
|
|
|
}
|
2012-03-28 05:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-12-17 03:21:47 +00:00
|
|
|
let nyan : Cat = cat(52, 99);
|
2012-03-28 05:08:48 +00:00
|
|
|
nyan.eat();
|
|
|
|
}
|