joke_bot: Replace match with only one non-empty branch with if let

This commit is contained in:
Jonas Platte 2022-02-12 18:48:48 +01:00
parent 07ed3da86a
commit 459010939d
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -95,19 +95,17 @@ async fn run() -> Result<(), Box<dyn Error>> {
let message_futures = response.rooms.join.iter().map(|(room_id, room_info)| async move { let message_futures = response.rooms.join.iter().map(|(room_id, room_info)| async move {
// Use a regular for loop for the messages within one room to handle them sequentially // Use a regular for loop for the messages within one room to handle them sequentially
for e in &room_info.timeline.events { for e in &room_info.timeline.events {
match handle_messages(http_client, matrix_client, e, room_id, user_id).await { if let Err(err) =
Ok(_) => {} handle_messages(http_client, matrix_client, e, room_id, user_id).await
Err(err) => { {
eprintln!("failed to respond to message: {}", err) eprintln!("failed to respond to message: {}", err)
}
} }
} }
}); });
let invite_futures = response.rooms.invite.iter().map(|(room_id, _)| async move { let invite_futures = response.rooms.invite.iter().map(|(room_id, _)| async move {
match handle_invitations(http_client, matrix_client, room_id).await { if let Err(err) = handle_invitations(http_client, matrix_client, room_id).await {
Ok(_) => {} eprintln!("failed to accept invitation for room {}: {}", &room_id, err)
Err(err) => eprintln!("failed to accept invitation for room {}: {}", &room_id, err),
} }
}); });