From 580f5e9be72ca5f14d0e326cdf7ba710f56f01b1 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 21:00:38 -0400 Subject: [PATCH] tsk-73: Code cleanup: : --- src/song.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/song.rs b/src/song.rs index 27cd011..af0f209 100644 --- a/src/song.rs +++ b/src/song.rs @@ -71,21 +71,22 @@ impl Song { pub fn song_path(&self) -> Result { if self.directory.is_empty() { - return Err(std::io::Error::other("Directory does not exist")); + return Err(std::io::Error::other("Directory has not been initialized")); + } else if self.filename.is_empty() { + return Err(std::io::Error::other("Filename has not bee initialized")); } let directory = &self.directory; - let mut buffer: String = directory.clone(); let last_index = directory.len() - 1; if let Some(character) = directory.chars().nth(last_index) { - if character != '/' { - buffer += "/"; - } + let buffer: String = if character != '/' { + directory.clone() + "/" + } else { + directory.clone() + }; - buffer += &self.filename.clone(); - - Ok(buffer) + Ok(buffer + &self.filename.clone()) } else { Err(std::io::Error::other( "Could not access last character of directory",