From 9b7b2d49d5f3cae626a69f02060ccfc838d27f01 Mon Sep 17 00:00:00 2001 From: Ax333l Date: Fri, 3 Feb 2023 19:29:47 +0100 Subject: [PATCH] style(clippy): use variables in the format string directly --- src/commands/misc.rs | 4 ++-- src/commands/moderation.rs | 2 +- src/utils/code_embed/url_parser.rs | 15 +++++++-------- src/utils/poll.rs | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/commands/misc.rs b/src/commands/misc.rs index 8d75534..87736b7 100644 --- a/src/commands/misc.rs +++ b/src/commands/misc.rs @@ -42,7 +42,7 @@ pub async fn reply( channel.say(http, &message).await?; } - send_ephermal(&ctx, &format!("Response: {}", message)).await?; + send_ephermal(&ctx, &format!("Response: {message}")).await?; Ok(()) } @@ -82,7 +82,7 @@ pub async fn poll( r.create_button(|b| { b.label("Vote") .emoji(ReactionType::Unicode("🗳️".to_string())) - .custom_id(format!("poll:{}:{}", id, age)) + .custom_id(format!("poll:{id}:{age}")) }) }) }) diff --git a/src/commands/moderation.rs b/src/commands/moderation.rs index c9e961b..3c3250a 100644 --- a/src/commands/moderation.rs +++ b/src/commands/moderation.rs @@ -318,7 +318,7 @@ pub async fn mute( } .await; - let duration = unmute_time.map(|time| format!("", time)); + let duration = unmute_time.map(|time| format!("")); respond_moderation( &ctx, diff --git a/src/utils/code_embed/url_parser.rs b/src/utils/code_embed/url_parser.rs index 154746f..ffc6432 100644 --- a/src/utils/code_embed/url_parser.rs +++ b/src/utils/code_embed/url_parser.rs @@ -69,8 +69,7 @@ impl CodeUrlParser for GitHubCodeUrl { } let raw_url = format!( - "https://raw.githubusercontent.com/{}/{}/{}{}", - user, repo, branch_or_sha, path + "https://raw.githubusercontent.com/{user}/{repo}/{branch_or_sha}{path}" ); let mut code_url = CodeUrl { @@ -133,7 +132,7 @@ impl CodeUrlParser for GitHubCodeUrl { let end = end - 1; if start > end || start >= lines.len() || end >= lines.len() { - return Err(ParserError::InvalidFragment(format!("{}-{}", start, end))); + return Err(ParserError::InvalidFragment(format!("{start}-{end}"))); } let mut code_block = String::new(); @@ -177,19 +176,19 @@ impl fmt::Display for ParserError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ParserError::Error(e) => { - write!(f, "Error: {}", e) + write!(f, "Error: {e}") }, ParserError::WrongParserError(expected, got) => { - write!(f, "Expected parser {}, got {}", expected, got) + write!(f, "Expected parser {expected}, got {got}") }, ParserError::ConversionError(conversion_error) => { - write!(f, "Conversion error: {}", conversion_error) + write!(f, "Conversion error: {conversion_error}") }, ParserError::InvalidFragment(fragment) => { - write!(f, "Invalid fragment: {}", fragment) + write!(f, "Invalid fragment: {fragment}") }, ParserError::FailedToGetCode(error) => { - write!(f, "Failed to get code: {}", error) + write!(f, "Failed to get code: {error}") }, } } diff --git a/src/utils/poll.rs b/src/utils/poll.rs index df7ca52..d23d4cf 100644 --- a/src/utils/poll.rs +++ b/src/utils/poll.rs @@ -48,7 +48,7 @@ pub async fn handle_poll( .create_interaction_response(&ctx.http, |r| { r.interaction_response_data(|m| { if let Ok(token) = result.as_deref() { - let url = format!("https://revanced.app/poll#{}", token); + let url = format!("https://revanced.app/poll#{token}"); m.components(|c| { c.create_action_row(|r| { r.create_button(|b| {