+use serde::{Serialize, Deserialize};
+
+#[derive(Serialize, Deserialize, Debug)]
+enum Social {
+ Twitter(String),
+ ICQ(u64),
+ Nothing,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+struct Contact {
+ name: String,
+ phone: u32,
+ social: Social,
+}
+
+type Contacts = Vec<Contact>;
+
+fn build_contacts() -> Contacts {
+ vec![
+ Contact { name: "John".to_string(), phone: 12345, social: Social::Twitter("@the_john".to_string()) },
+ Contact { name: "Mary".to_string(), phone: 9876543, social: Social::ICQ(111234) },
+ Contact { name: "Jane".to_string(), phone: 555555, social: Social::Nothing },
+ ]
+}
+
+fn create_contacts() {
+ let contacts = build_contacts();
+ // FIXME: Use ? and return Result
+ let serialized = serde_json::to_string(&contacts).unwrap();
+ println!("serialized: {}", serialized);
+}
+
+fn main() {
+ create_contacts();
+}