Save the data to the list file when updated

This commit is contained in:
Paul van Tilburg 2017-12-27 20:56:54 +01:00
parent c72b3d1669
commit 9be9808463
1 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,12 @@ impl List {
pub fn update_data(&mut self, data : &String) {
self.data = data.clone();
let mut file = File::create(&self.path)
.expect(&format!("Cannot open list file {}",
self.path.to_str().unwrap()));
file.write_all(data.as_bytes())
.expect(&format!("Cannot write list file {}",
self.path.to_str().unwrap()));
}
pub fn load_all() -> Vec<Self> {