Skip to content

Commit

Permalink
Use if let Some instead of checking is_some and then unwrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
RubberDuckShobe committed Mar 30, 2024
1 parent 10cb4ab commit aa0dd2a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/hooking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,21 @@ unsafe fn send_hook(
}

// Add Steam auth ticket when fetching song ID
if url.ends_with("/as_steamlogin/game_fetchsongid_unicode.php") && global_data.ticket.is_some()
{
new_form_data.set_one("ticket", global_data.ticket.as_ref().unwrap());
if url.ends_with("/as_steamlogin/game_fetchsongid_unicode.php") {
if let Some(ticket) = &global_data.ticket {
new_form_data.set_one("ticket", ticket);
}
}

// Add recording and release MBIDs (if present), when fetching song ID and submitting a score
if url.ends_with("/as_steamlogin/game_fetchsongid_unicode.php")
|| url.ends_with("/as_steamlogin/game_SendRideSteamVerified.php")
{
if global_data.current_mbid.is_some() {
new_form_data.set_one("mbid", global_data.current_mbid.as_ref().unwrap());
if let Some(mbid) = &global_data.current_mbid {
new_form_data.set_one("mbid", mbid);
}
if global_data.current_release_mbid.is_some() {
new_form_data.set_one(
"releasembid",
global_data.current_release_mbid.as_ref().unwrap(),
);
if let Some(release_mbid) = &global_data.current_release_mbid {
new_form_data.set_one("releasembid", release_mbid);
}
}

Expand Down

0 comments on commit aa0dd2a

Please sign in to comment.