-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib.rs
40 lines (36 loc) · 740 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#[cfg(feature = "python")]
use pyo3::prelude::pyclass;
mod bradley_terry;
mod counting;
mod elo;
mod linalg;
#[cfg(feature = "python")]
mod python;
mod utils;
#[cfg_attr(feature = "python", pyclass(module = "evalica", eq, eq_int))]
#[repr(u8)]
#[derive(Clone, Debug, PartialEq, Hash)]
pub enum Winner {
X,
Y,
Draw,
}
impl From<u8> for Winner {
fn from(value: u8) -> Self {
match value {
0 => Self::Draw,
1 => Self::X,
2 => Self::Y,
_ => panic!("Invalid value: {}", value),
}
}
}
impl Into<u8> for Winner {
fn into(self) -> u8 {
match self {
Self::Draw => 0,
Self::X => 1,
Self::Y => 2,
}
}
}