From d3600c46da7a19b00bcd9d70421689211f34d20e Mon Sep 17 00:00:00 2001 From: Liam Fitzpatrick Date: Fri, 12 Apr 2024 08:54:00 -0400 Subject: [PATCH] fixed warnings --- src/collection.rs | 2 +- src/table.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/collection.rs b/src/collection.rs index dd13796..89892e6 100644 --- a/src/collection.rs +++ b/src/collection.rs @@ -41,7 +41,7 @@ impl Collection where T: DeserializeOwned { - pub fn load(mut file: File) -> Result, Box>{ + pub fn load(file: File) -> Result, Box>{ let n = file.metadata()?.len(); let mut reader = BufReader::new(file); let mut current_position = reader.stream_position()?; diff --git a/src/table.rs b/src/table.rs index 0dc43b9..5b7cc5e 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1,4 +1,3 @@ -use core::fmt; use std::{fs::{File,remove_file}, io::{Seek, BufReader}}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::error::Error; @@ -21,7 +20,7 @@ impl TableRow { fn new(id: usize, name: Uuid, entry: Collection, file_pos: u64) -> Result>{ let path = format!("{}.bson", name); - let mut file = File::create(&path)?; + let file = File::create(&path)?; entry.save(file)?; Ok( TableRow { id: id, name: name, num_entries: entry.entries.len(), path: path, file_pos: file_pos } @@ -87,7 +86,7 @@ impl Table { pub fn add_to_collection(&mut self, collection_id : usize, object: T) -> Result<(), Box>{ // TODO: this currently wipes out files and rewrites the entirety of them. Update to only change the sections that need to change. - let selected_row = self.getRow(collection_id); + let selected_row = self.get_row(collection_id); let mut selected_collection: Collection = Collection::load(File::open(&selected_row.path)?)?; remove_file(&selected_row.path)?; selected_collection.entries.push(object); @@ -99,7 +98,7 @@ impl Table { pub fn update(&mut self, id: usize, entry: Collection)-> Result<(), Box>{ // TODO: this currently wipes out files and rewrites the entirety of them. Update to only change the sections that need to change. - let selected_row = self.getRow(id); + let selected_row = self.get_row(id); remove_file(&selected_row.path)?; selected_row.num_entries = entry.entries.len(); entry.save(File::create(&selected_row.path)?)?; @@ -107,7 +106,7 @@ impl Table { Ok(()) } - fn getRow(&mut self, id: usize) -> &mut TableRow{ + fn get_row(&mut self, id: usize) -> &mut TableRow{ let row_index = self.rows.iter().position(move |row |{ row.id == id }).expect("Failed to find that row in table."); @@ -115,8 +114,8 @@ impl Table { } pub fn get(&mut self, id: usize)-> Result, Box>{ - let table_row = self.getRow(id); - let mut file = File::open(&table_row.path)?; + let table_row = self.get_row(id); + let file = File::open(&table_row.path)?; Collection::load(file) } } \ No newline at end of file