From 27c75666d20793d0a7f7b816fa821f91691a260d Mon Sep 17 00:00:00 2001 From: Stephen <webmaster@scd31.com> Date: Sat, 28 Jan 2023 09:06:59 -0400 Subject: [PATCH] clippy fixes --- src/handlers/react.rs | 6 +++--- src/handlers/starboard.rs | 4 ++-- src/handlers/xbasic.rs | 18 +++++++++--------- src/main.rs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/handlers/react.rs b/src/handlers/react.rs index d586e92..acf3d7a 100644 --- a/src/handlers/react.rs +++ b/src/handlers/react.rs @@ -23,7 +23,7 @@ fn map_lookup(msg: &str) -> Option<&'static str> { // We lose the O(1) benefits of the hashmap // But whatever. It doesn't need to be fast for (k, v) in EMOJI_MAP.entries() { - if &msg == k || msg == format!("{}s", k) { + if &msg == k || msg == format!("{k}s") { return Some(v); } } @@ -56,12 +56,12 @@ impl LineHandler for ReactHandler { let reaction_type = match ReactionType::from_str(r) { Ok(x) => x, Err(x) => { - println!("Could not react: {}", x); + eprintln!("Could not react: {x}"); return; } }; if let Err(e) = msg.react(&ctx, reaction_type).await { - println!("Error reacting: {}", e); + eprintln!("Error reacting: {e}"); } } } diff --git a/src/handlers/starboard.rs b/src/handlers/starboard.rs index 4fdc3b9..e70d50f 100644 --- a/src/handlers/starboard.rs +++ b/src/handlers/starboard.rs @@ -231,13 +231,13 @@ impl StarboardHandler { impl ReactionHandler for StarboardHandler { async fn reaction_add(&self, ctx: &Context, reaction: &Reaction) { if let Err(e) = self.handle_reaction(ctx, reaction).await { - eprintln!("Error in starboard: {:?}", e); + eprintln!("Error in starboard: {e:?}"); } } async fn reaction_del(&self, ctx: &Context, reaction: &Reaction) { if let Err(e) = self.handle_reaction(ctx, reaction).await { - eprintln!("Error in starboard: {:?}", e); + eprintln!("Error in starboard: {e:?}"); } } } diff --git a/src/handlers/xbasic.rs b/src/handlers/xbasic.rs index 55692f0..5bb6d59 100644 --- a/src/handlers/xbasic.rs +++ b/src/handlers/xbasic.rs @@ -106,7 +106,7 @@ impl XbasicHandler { if let Some(name) = line.strip_prefix("PUB ") { if self.publish_program(name, msg, ctx).await.is_none() { msg.channel_id - .say(&ctx, format!("Could not publish {}.", name)) + .say(&ctx, format!("Could not publish {name}.")) .await .unwrap(); } @@ -115,7 +115,7 @@ impl XbasicHandler { if let Some(name) = line.strip_prefix("UNPUB ") { if self.unpublish_program(name, msg, ctx).await.is_none() { msg.channel_id - .say(&ctx, &format!("Could not unpublish {}.", name)) + .say(&ctx, &format!("Could not unpublish {name}.")) .await .unwrap(); } @@ -126,7 +126,7 @@ impl XbasicHandler { Ok(id) => { if self.load_published_program(msg, ctx, id).await.is_none() { msg.channel_id - .say(&ctx, format!("Could not load {}.", id)) + .say(&ctx, format!("Could not load {id}.")) .await .unwrap(); } @@ -223,7 +223,7 @@ impl XbasicHandler { Program::set_program_published(self.conn.lock().await.borrow(), name, msg.author.id, true)?; msg.channel_id - .say(&ctx, format!("Published {}.", name)) + .say(&ctx, format!("Published {name}.")) .await .unwrap(); @@ -239,7 +239,7 @@ impl XbasicHandler { )?; msg.channel_id - .say(&ctx, format!("Unpublished {}.", name)) + .say(&ctx, format!("Unpublished {name}.")) .await .unwrap(); @@ -251,7 +251,7 @@ impl XbasicHandler { .load_published_program(self.conn.lock().await.borrow(), id)?; msg.channel_id - .say(&ctx, format!("Loaded {} (\"{}\") into memory.", id, name)) + .say(&ctx, format!("Loaded {id} (\"{name}\") into memory.")) .await .unwrap(); @@ -280,7 +280,7 @@ impl XbasicHandler { match result { Some(_) => { msg.channel_id - .say(&ctx, format!("Loaded {} into memory.", name)) + .say(&ctx, format!("Loaded {name} into memory.")) .await .unwrap(); } @@ -302,7 +302,7 @@ impl XbasicHandler { match result { Some(_) => { msg.channel_id - .say(&ctx, format!("Saved as {}", name)) + .say(&ctx, format!("Saved as {name}")) .await .unwrap(); } @@ -358,7 +358,7 @@ impl XbasicHandler { let mut xb = xbb.build(); - let _ = xb.run(&format!("{}\n", code)); + let _ = xb.run(&format!("{code}\n")); let errors = if xb.error_handler.had_errors || xb.error_handler.had_runtime_error { Some(xb.error_handler.errors.join("\n")) diff --git a/src/main.rs b/src/main.rs index 158132c..f0997ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,6 @@ async fn main() { .await .expect("Error creating client"); if let Err(e) = client.start().await { - eprintln!("Client error: {}", e); + eprintln!("Client error: {e}"); } } -- GitLab