SHARE
TWEET

Untitled

a guest Oct 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use serde_derive::{Serialize, Deserialize}; // 1.0.101
  2. use serde_json; // 1.0.40
  3.  
  4. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
  5. #[serde(untagged)]
  6. pub enum Aud {
  7.     One(String),
  8.     Many(Vec<String>),
  9. }
  10. fn main() {
  11.     let foo = Aud::One ("CBr3zBlrKBbwmxOAM1avZQ==".into());
  12.     let bar = Aud::Many (vec![ "1".into(), "2".into() ]);
  13.     let foo_s = serde_json::to_string (&foo).unwrap();
  14.     let bar_s = serde_json::to_string (&bar).unwrap();
  15.     println!("{} - {}", foo_s, foo_s.len());
  16.     println!("{} - {}", bar_s, bar_s.len());
  17. }
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