From d652d8588dfa8912d4c5d9e76479298e30600af1 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 4 Jul 2025 16:34:28 -0400 Subject: [PATCH] Warning changes --- src/lib.rs | 5 +---- src/meta.rs | 5 ++--- src/properties.rs | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c27f28d..287e3ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,10 +34,7 @@ pub mod test_util { let src_path = std::path::Path::new(source_path); let dest_path = std::path::Path::new(destination_path); - match std::fs::copy(src_path, dest_path) { - Ok(bytes) => Ok(bytes), - Err(err) => Err(err), - } + std::fs::copy(src_path, dest_path) } pub fn file_exists(directory: &String, filename: &String) -> Result { diff --git a/src/meta.rs b/src/meta.rs index eab3a79..7cb6088 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -278,12 +278,11 @@ mod tests { // use super::*; - mod get { use super::super::metadata::get_meta; - use crate::types; use crate::test_util::util; use crate::test_util::util::{file_exists, get_full_path}; + use crate::types; #[test] fn test_get_title() { @@ -537,9 +536,9 @@ mod tests { mod set { use super::super::metadata::{get_meta, set_meta}; - use crate::types; use crate::test_util::util; use crate::test_util::util::{file_exists, get_full_path}; + use crate::types; #[test] fn test_set_title() { diff --git a/src/properties.rs b/src/properties.rs index c52f140..288fb3c 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -2,23 +2,22 @@ use lofty::file::AudioFile; #[derive(Debug, Default, Clone)] pub struct Duration { - pub val: i32 + pub val: i32, } -pub fn get_duration(song_path: &String) -> Result { +pub fn get_duration(song_path: &String) -> Result { match std::fs::File::open(song_path) { - Ok(mut content) => match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new(),) { - Ok(flac_file) => { - let properties = flac_file.properties(); - Ok(properties.duration()) - } - Err(err) => { - Err(std::io::Error::other(err.to_string())) + Ok(mut content) => { + match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new()) + { + Ok(flac_file) => { + let properties = flac_file.properties(); + Ok(properties.duration()) + } + Err(err) => Err(std::io::Error::other(err.to_string())), } } - Err(err) => { - Err(err) - } + Err(err) => Err(err), } } @@ -39,7 +38,10 @@ mod tests { let song_duration: u64 = 41; let fetched_song_duration = duration.as_secs(); - assert_eq!(song_duration, fetched_song_duration, "Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})"); + assert_eq!( + song_duration, fetched_song_duration, + "Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})" + ); } Err(err) => { assert!(false, "Error: {err:?}");