Created
April 9, 2017 20:41
-
-
Save jacobmischka/7f3ba41ad4dec0c052d3088c773f5998 to your computer and use it in GitHub Desktop.
PatientSex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait CodeValue { | |
fn value(&self) -> &str; | |
fn from(value: &str) -> Self; | |
} | |
pub enum PatientSex { | |
Male, | |
Female, | |
Missing, | |
Unknown | |
} | |
impl CodeValue for PatientSex { | |
fn value(&self) -> &str { | |
use self::PatientSex::*; | |
match *self { | |
Male => "Male", | |
Female => "Female", | |
Missing => "Missing", | |
Unknown => "Unknown" | |
} | |
} | |
fn from(sex: &str) -> PatientSex { | |
use self::PatientSex::*; | |
match sex { | |
"M" | "Male" => Male, | |
"F" | "Female" => Female, | |
"" => Missing, | |
_ => Unknown | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment