diff --git a/src/db.rs b/src/db.rs index 8aec813..d446250 100644 --- a/src/db.rs +++ b/src/db.rs @@ -53,7 +53,8 @@ impl Ord for Item { } pub struct DB { - pub items: HashSet:: + pub items: HashSet::, + path: String } impl DB { @@ -72,7 +73,8 @@ impl DB { } } let result = DB { - items: items + items: items, + path: String::from(path) }; Ok(result) } @@ -82,11 +84,11 @@ impl DB { self.items.contains(&item) } - pub fn dump(&self, path: &str) -> io::Result<()> { + pub fn dump(&self) -> io::Result<()> { let mut file = fs::OpenOptions::new() .write(true) .append(false) - .open(path)?; + .open(&self.path)?; for item in self.items.iter() { writeln!(file, "{}", item.id)?; diff --git a/src/main.rs b/src/main.rs index d958211..f2b7aac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,7 @@ fn add(id: &String) -> io::Result<()> { } db.items.insert(Item::from(id.clone())); - db.dump(&*STORAGE_PATH)?; + db.dump()?; Ok(()) }