Step 5: Page 30
This commit is contained in:
@@ -49,6 +49,12 @@ impl TodoList {
|
|||||||
Ok(TodoList::new())
|
Ok(TodoList::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn save_to_file(&self, filename: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let json = serde_json::to_string_pretty(self)?;
|
||||||
|
fs::write(filename, json)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user