blob: a8a0a72dd3cbd185b355f86a7eeb20ebd09b6a00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
enum Animal {
Dog (~str, float),
Cat { name: ~str, weight: float }
}
pub fn main() {
let mut a: Animal = Dog(~"Cocoa", 37.2);
a = Cat{ name: ~"Spotty", weight: 2.7 };
// permuting the fields should work too
let c = Cat { weight: 3.1, name: ~"Spreckles" };
}
|