Created
January 24, 2020 13:00
-
-
Save rust-play/e6b49d5be4cb8bb02265781583e10098 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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
#[allow(dead_code)] | |
#[allow(non_snake_case)] | |
#[allow(non_camel_case_types)] | |
mod NumberFormat { | |
#[derive(Debug)] | |
pub enum Style { | |
DECIMAL, | |
CURRENCY, | |
PERCENT, | |
} | |
impl Default for Style { | |
fn default() -> Style { | |
Style::DECIMAL | |
} | |
} | |
#[derive(Debug)] | |
pub enum Opt { | |
style(Style), | |
currency(String), | |
maximumFractionDigits(i32), | |
} | |
pub fn build(locale: &str, options: &[Opt]) { | |
print!("{:?} {:?}", locale, options); | |
} | |
} | |
fn main() { | |
NumberFormat::build("pt-BR", &[ | |
NumberFormat::Opt::style(NumberFormat::Style::CURRENCY), | |
NumberFormat::Opt::currency(String::from("EUR")), | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment