From 736a0e8852291f4c78d9dd068fdd8f63af7b6bc7 Mon Sep 17 00:00:00 2001 From: Ash <spook123@gmail.com> Date: Wed, 25 Mar 2020 20:21:19 +0800 Subject: [PATCH] use enumerate() and fix indents --- src/reaction_roles.rs | 6 ++---- src/user_management.rs | 2 +- src/voting.rs | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/reaction_roles.rs b/src/reaction_roles.rs index 3c4ba9e..779aaf9 100644 --- a/src/reaction_roles.rs +++ b/src/reaction_roles.rs @@ -101,9 +101,7 @@ pub fn sync_all_role_reactions(ctx: &Context) { let mut roles_to_remove: HashMap<UserId, Vec<RoleId>> = HashMap::from_iter(all_members.iter().map(|m| (m.user_id(), Vec::new()))); - let mut i = 0; - for (message, mapping) in messages_with_role_mappings { - i += 1; + for (i, (message, mapping)) in messages_with_role_mappings.iter().enumerate() { info!(" Sync: prossessing message #{}", i); for react in &message.reactions { let react_as_string = get_string_from_react(&react.reaction_type); @@ -120,7 +118,7 @@ pub fn sync_all_role_reactions(ctx: &Context) { warn!(" need to implement react removal"); } } - for (react, role) in mapping { + for (react, role) in *mapping { info!(" message #{}: processing react '{}'", i, react); // TODO: proper pagination for the unlikely scenario that there are more than 100 (255?) reactions? let reaction_type = get_react_from_string(react.clone(), guild.clone()); diff --git a/src/user_management.rs b/src/user_management.rs index 955d4b9..82de3b1 100644 --- a/src/user_management.rs +++ b/src/user_management.rs @@ -64,7 +64,7 @@ impl Commands { "Error sending message: {:?}", // TODO convert to email msg.channel_id - .say(&ctx.http, format!("Hey {} here's that token you ordered: {}\nIf this wasn't you just ignore this.", account_name, generate_token(&msg.author, account_name))) + .say(&ctx.http, format!("Hey {} here's that token you ordered: {}\nIf this wasn't you just ignore this.", account_name, generate_token(&msg.author, account_name))) ); e!("Error deleting register message: {:?}", msg.delete(ctx)); } diff --git a/src/voting.rs b/src/voting.rs index 4241121..4920fee 100644 --- a/src/voting.rs +++ b/src/voting.rs @@ -265,9 +265,9 @@ fn update_motion( ); let update_status = |e: &mut serenity::builder::CreateEmbed, - status: &str, - last_status_full: String, - topic: &str| { + status: &str, + last_status_full: String, + topic: &str| { let last_status = last_status_full.lines().next().expect("No previous status"); if last_status == status { e.field("Status", last_status_full, true); -- GitLab