+use std::fs;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
// FIXME: Use ? and return Result
let serialized = serde_json::to_string(&contacts).unwrap();
println!("serialized: {}", serialized);
+ let mut f = fs::File::create("/tmp/contacts.json").unwrap_or_else(|e| panic!("Could not create /tmp/contacts.json: {:?}", e));
+ serde_json::to_writer_pretty(&mut f, &contacts).unwrap_or_else(|e| panic!("Could not serialize contacts: {:?}", e));
}
fn main() {