rust std change (#42)

Reviewed-on: #42
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-06-29 17:37:13 +00:00
committed by phoenix
parent 47475639b0
commit f37c445908
6 changed files with 501 additions and 18 deletions
+3 -10
View File
@@ -67,10 +67,7 @@ impl Song {
pub fn song_path(&self) -> Result<String, std::io::Error> {
if self.directory.is_empty() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Directory does not exist",
));
return Err(std::io::Error::other("Directory does not exist"));
}
let directory = &self.directory;
@@ -86,8 +83,7 @@ impl Song {
Ok(buffer)
} else {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
Err(std::io::Error::other(
"Could not access last character of directory",
))
}
@@ -103,10 +99,7 @@ impl Song {
file.read_to_end(&mut buffer)?;
if buffer.is_empty() {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"File is empty",
))
Err(std::io::Error::other("File is empty"))
} else {
Ok(buffer)
}