refactor: don't use snake case

This commit is contained in:
Anna 2018-10-08 11:28:51 -04:00
parent e6e1f8ff51
commit d6f914b9c7
1 changed files with 18 additions and 19 deletions

View File

@ -1,28 +1,27 @@
macro_rules! ffxiv_enum { macro_rules! ffxiv_enum {
($(#[$meta:meta])* $name:ident { $($variant:ident => $str_repr:expr),+$(,)? }) => { ($(#[$meta:meta])* $name:ident { $($variant:ident => $str_repr:expr),+$(,)? }) => {
$(#[$meta])* $(#[$meta])*
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")] pub enum $name {
pub enum $name { $($variant,)+
$($variant,)+ }
impl $name {
pub fn parse(s: &str) -> Option<Self> {
let res = match s.to_lowercase().as_str() {
$($str_repr => $name::$variant,)+
_ => return None,
};
Some(res)
} }
impl $name { pub fn name(&self) -> &str {
pub fn parse(s: &str) -> Option<Self> { match *self {
let res = match s.to_lowercase().as_str() { $($name::$variant => $str_repr,)+
$($str_repr => $name::$variant,)+
_ => return None,
};
Some(res)
}
pub fn name(&self) -> &str {
match *self {
$($name::$variant => $str_repr,)+
}
} }
} }
} }
}
} }
pub mod character; pub mod character;