From bc4278efe1ea0189693a6f1bdca08d2745d3fa5d Mon Sep 17 00:00:00 2001 From: Coin de Gamma Date: Wed, 4 Sep 2024 17:26:12 +0000 Subject: [PATCH] fix add --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index bd58cab..14f8144 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,7 +61,7 @@ fn init() -> io::Result<()> { } fn add(id: &String) -> io::Result<()> { - let db = DB::new(STORAGE_PATH)?; + let mut db = DB::new(STORAGE_PATH)?; if db.items.contains(id) { // TODO: ask to edit existing in outer function which invoked this one return Err(io::Error::new( @@ -70,6 +70,7 @@ fn add(id: &String) -> io::Result<()> { )) } + db.items.insert(id.clone()); db.dump(STORAGE_PATH)?; Ok(())