]>
Commit | Line | Data |
---|---|---|
ba9703b0 | 1 | // check-pass |
94b46f34 XL |
2 | // https://github.com/rust-lang/rust/issues/51300 |
3 | ||
4 | #[derive(PartialEq, Eq, Clone, Copy)] | |
5 | pub struct Stat { | |
6 | pub id: u8, | |
7 | pub index: usize, | |
8 | } | |
9 | ||
10 | impl Stat { | |
11 | pub const STUDENT_HAPPINESS: Stat = Stat{ | |
12 | id: 0, | |
13 | index: 0, | |
14 | }; | |
15 | pub const STUDENT_HUNGER: Stat = Stat{ | |
16 | id: 0, | |
17 | index: Self::STUDENT_HAPPINESS.index + 1, | |
18 | }; | |
19 | ||
20 | } | |
21 | ||
22 | pub fn from_index(id: u8, index: usize) -> Option<Stat> { | |
23 | let stat = Stat{id, index}; | |
24 | match stat { | |
25 | Stat::STUDENT_HAPPINESS => Some(Stat::STUDENT_HAPPINESS), | |
26 | Stat::STUDENT_HUNGER => Some(Stat::STUDENT_HUNGER), | |
27 | _ => None, | |
28 | } | |
29 | } | |
30 | ||
31 | fn main() { } |