Step 5: Page 30

This commit is contained in:
2026-02-05 11:13:41 +01:00
parent e0088eb1c7
commit 835b66e708

View File

@@ -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();