SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use serde::Deserialize;
  2. use serde_yaml::Value;
  3.  
  4. #[derive(Deserialize, Debug)]
  5. enum EnumType {
  6.     A,
  7.     B,
  8.     C,
  9. }
  10.  
  11. #[derive(Deserialize, Debug)]
  12. struct MyConfig {
  13.     a: Option<String>,
  14.     b: EnumType,
  15. }
  16.  
  17. fn main() {
  18.     let config_yml = "a: ...\nb: A\n";
  19.  
  20.     println!("{:?}", serde_yaml::from_str::<MyConfig>(config_yml).unwrap());
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top