Compare commits
1 Commits
v0.1.3
...
95d13370c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d13370c2 |
@@ -21,6 +21,28 @@ impl DanceRole {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ParseDanceRoleError;
|
||||||
|
|
||||||
|
impl std::fmt::Display for ParseDanceRoleError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
write!(f, "failed to parse DanceRole")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl std::error::Error for ParseDanceRoleError {}
|
||||||
|
|
||||||
|
impl TryFrom<&str> for DanceRole {
|
||||||
|
type Error = ParseDanceRoleError;
|
||||||
|
|
||||||
|
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||||
|
match value.to_lowercase().as_str() {
|
||||||
|
"leader" => Ok(DanceRole::Leader),
|
||||||
|
"follower" => Ok(DanceRole::Follower),
|
||||||
|
_ => Err(ParseDanceRoleError),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, PartialEq, Eq)]
|
#[derive(serde::Deserialize, Debug, PartialEq, Eq)]
|
||||||
pub enum DanceRank {
|
pub enum DanceRank {
|
||||||
Newcomer,
|
Newcomer,
|
||||||
|
|||||||
Reference in New Issue
Block a user