Skip to content

Commit 7e7868e

Browse files
committed
Change the definition of post_current_song()
There was redundant match statement in main.rs because post_current_song() returns Result<(), String>.
1 parent b126cd9 commit 7e7868e

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

base/src/main.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@ async fn main() {
7979
std::process::exit(0);
8080
}
8181
1 => {
82-
match post_current_song(&tapi, &mut sapi).await {
83-
Ok(()) => {
84-
println!{"Posted Successfully"};
85-
}
86-
Err(e) => {
87-
eprintln!{"Error!\nExpected reason: {}", e};
88-
}
89-
}
82+
post_current_song(&tapi, &mut sapi).await
9083
},
9184
_ => {
9285
eprintln!{"Unknown choice selected. Please try again"};

base/src/main_logics.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ pub async fn post_current_song_on_spotify(
5050
}
5151
}
5252

53-
pub async fn post_current_song(
54-
papi: &dyn PostAPI,
55-
sapi: &mut SpotifyAPI<'_>
56-
) -> Result<(), String> {
53+
pub async fn post_current_song(papi: &dyn PostAPI, sapi: &mut SpotifyAPI<'_>) {
5754
match sapi.fetch_current_song().await {
5855
Ok(raw) => {
5956
let resp = sapi.parse_current_song_result(raw);
@@ -66,12 +63,12 @@ pub async fn post_current_song(
6663
};
6764

6865
match post_result {
69-
Ok(_) => Ok(()),
70-
Err(reason) => Err(reason.to_string())
66+
Ok(_) => println!{"Posted Successfully."},
67+
Err(reason) => eprintln!{"Error!\nExpected reason: {}", reason.to_string()}
7168
}
7269
}
7370
Err(reason) => {
74-
Err(reason.to_string())
71+
eprintln!{"Error!\nExpected reason: {}", reason.to_string()};
7572
}
7673
}
7774
}

0 commit comments

Comments
 (0)