moved getting shelf to universal function instead of whatever I was doing befoer
This commit is contained in:
11
src/utils.rs
11
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,
|
||||
|
||||
Reference in New Issue
Block a user