rust/src/test/run-pass/classes-simple-method.rs

25 lines
361 B
Rust
Raw Normal View History

2012-08-15 18:46:55 -07:00
struct cat {
priv {
2012-03-26 18:35:18 -07:00
let mut meows : uint;
}
let how_hungry : int;
fn speak() {}
}
2012-09-05 15:58:43 -07:00
fn cat(in_x : uint, in_y : int) -> cat {
cat {
meows: in_x,
how_hungry: in_y
}
}
fn main() {
let nyan : cat = cat(52u, 99);
let kitty = cat(1000u, 2);
assert(nyan.how_hungry == 99);
assert(kitty.how_hungry == 2);
nyan.speak();
}