Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 10, 2019 15:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rust-play/2c6260b63905b0953434c96f7ad4055e to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
use serde; // 1.0.94
use serde_derive; // 1.0.94
use toml; // 0.5.1
use serde_derive::Deserialize;
use std::collections::HashMap;
#[derive(Deserialize, Debug, Eq, PartialEq, Hash)]
#[serde(rename_all = "snake_case")]
enum StepType {
Jump,
DoABarrelRoll
}
fn main() {
let toml = r#"do_a_barrel_roll = true"#;
let parsed: HashMap<StepType, String> = toml::from_str(toml).unwrap();
println!("{:?}", parsed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment