use std::fs;
use std::error::Error;
+
use serde::{Serialize, Deserialize};
const DB_PATH: &str = "/tmp/contacts.json";
fn create_contacts() -> Result<(), Box<dyn Error>> {
let contacts = build_contacts();
let serialized = serde_json::to_string(&contacts)?;
- println!("serialized: {}", serialized);
+ log::debug!("serialized: {}", &serialized);
let mut f = fs::File::create(DB_PATH)?;
serde_json::to_writer_pretty(&mut f, &contacts)?;
Ok(())
}
fn main() -> Result<(), Box<dyn Error>> {
+ env_logger::init();
create_contacts()?;
let contacts = load_contacts()?;
- println!("deserialized: {:?}", contacts);
+ println!("deserialized: {:?}", &contacts);
Ok(())
}