Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 24, 2020 13:00
Show Gist options
  • Save rust-play/e6b49d5be4cb8bb02265781583e10098 to your computer and use it in GitHub Desktop.
Save rust-play/e6b49d5be4cb8bb02265781583e10098 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#[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