- 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));
+ let mut f = fs::File::create("/tmp/contacts.json")?;
+ serde_json::to_writer_pretty(&mut f, &contacts)?;
+ Ok(())