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,