Fix cargo clippy warnings

This commit is contained in:
Philip Kristoffersen
2021-09-25 12:04:12 +02:00
parent d634a26035
commit 993251156d
4 changed files with 7 additions and 11 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ fn get_manifest_dir_path(
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ {
//No path defined for epic gamestore, and we cannot guess on linux //No path defined for epic gamestore, and we cannot guess on linux
return Err(PathNotDefined); Err(PathNotDefined)
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
+1 -1
View File
@@ -73,7 +73,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
fn save_shortcuts(shortcuts: &Vec<Shortcut>, path: &Path) { fn save_shortcuts(shortcuts: &Vec<Shortcut>, path: &Path) {
let new_content = shortcuts_to_bytes(shortcuts); let new_content = shortcuts_to_bytes(shortcuts);
let mut file = File::create(path).unwrap(); let mut file = File::create(path).unwrap();
file.write(new_content.as_slice()).unwrap(); file.write_all(new_content.as_slice()).unwrap();
} }
fn update_platform_shortcuts<P, T, E>(platform: &P, current_shortcuts: &mut Vec<ShortcutOwned>) fn update_platform_shortcuts<P, T, E>(platform: &P, current_shortcuts: &mut Vec<ShortcutOwned>)
+3 -7
View File
@@ -2,8 +2,6 @@ use std::{collections::HashMap, fs::File, io::Write, path::Path};
type SearchMap = HashMap<u32, (String, usize)>; type SearchMap = HashMap<u32, (String, usize)>;
pub struct CachedSearch<'a> { pub struct CachedSearch<'a> {
search_map: SearchMap, search_map: SearchMap,
client: &'a steamgriddb_api::Client, client: &'a steamgriddb_api::Client,
@@ -26,7 +24,6 @@ impl<'a> CachedSearch<'a> {
app_id: u32, app_id: u32,
query: &str, query: &str,
) -> Result<Option<usize>, Box<dyn std::error::Error>> { ) -> Result<Option<usize>, Box<dyn std::error::Error>> {
let cached_result = self.search_map.get(&app_id); let cached_result = self.search_map.get(&app_id);
if let Some(result) = cached_result { if let Some(result) = cached_result {
return Ok(Some(result.1)); return Ok(Some(result.1));
@@ -38,7 +35,8 @@ impl<'a> CachedSearch<'a> {
} }
let first_item = &search[0]; let first_item = &search[0];
let assumed_id = first_item.id; let assumed_id = first_item.id;
self.search_map.insert(app_id, (query.to_owned(),assumed_id)); self.search_map
.insert(app_id, (query.to_owned(), assumed_id));
Ok(Some(assumed_id)) Ok(Some(assumed_id))
} }
@@ -48,9 +46,7 @@ fn get_search_map() -> SearchMap {
let path = Path::new("cache.json"); let path = Path::new("cache.json");
if path.exists() { if path.exists() {
let string = std::fs::read_to_string(path).unwrap(); let string = std::fs::read_to_string(path).unwrap();
let search_map = serde_json::from_str::<SearchMap>(&string).expect("Failed to parse cache.json")
serde_json::from_str::<SearchMap>(&string).expect("Failed to parse cache.json");
search_map
} else { } else {
SearchMap::new() SearchMap::new()
} }
+1 -1
View File
@@ -70,7 +70,7 @@ pub async fn download_images<'a, 'b>(
let mut file = File::create(path).unwrap(); let mut file = File::create(path).unwrap();
let response = reqwest::get(image.url).await?; let response = reqwest::get(image.url).await?;
let content = response.bytes().await?; let content = response.bytes().await?;
file.write(&content).unwrap(); file.write_all(&content).unwrap();
} }
} }
} }