From 949ff00396ba36386bcfec9134aa7a03fac74bb9 Mon Sep 17 00:00:00 2001 From: voidarc Date: Wed, 19 Aug 2026 09:47:05 +0100 Subject: [PATCH] moved getting shelf to universal function instead of whatever I was doing befoer --- src/utils.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index efd6fe9..6b83f36 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -43,6 +43,17 @@ pub fn save_library(library: Library) -> io::Result<()> { Ok(()) } +pub fn get_current_shelf(library: &mut Library) -> &mut Shelf { + // Rust variable nonsense (get current shelf index) + let shelves = &library.shelves; + let current_shelf = &library.current_shelf; + let shelf_index = get_shelf_index(shelves, current_shelf).unwrap_or(0); + + // Get current shelf index and push the file + let current_shelf = &mut library.shelves[*&shelf_index]; + return current_shelf; +} + pub fn initialize_library() -> Library { let default_shelf: Shelf = Shelf { id: 0,