From 4a1853532ad9b522efcabf15673a75baf8dee10e Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 18 Feb 2024 01:06:23 +0100 Subject: [PATCH] One round of cargo clippy --- youmubot-cf/src/embed.rs | 4 ++-- youmubot-cf/src/hook.rs | 2 +- youmubot-core/src/community/mod.rs | 2 +- youmubot-osu/src/discord/embeds.rs | 11 +++-------- youmubot-osu/src/discord/mod.rs | 2 +- youmubot-prelude/src/announcer.rs | 2 +- 6 files changed, 9 insertions(+), 14 deletions(-) diff --git a/youmubot-cf/src/embed.rs b/youmubot-cf/src/embed.rs index cb2ce5e..f45df1f 100644 --- a/youmubot-cf/src/embed.rs +++ b/youmubot-cf/src/embed.rs @@ -12,7 +12,7 @@ fn unwrap_or_ref<'a, T: ?Sized, B: Borrow>(opt: &'a Option, default: &'a T } /// Create an embed representing the user. -pub fn user_embed<'a>(user: &User) -> CreateEmbed { +pub fn user_embed(user: &User) -> CreateEmbed { let rank = unwrap_or_ref(&user.rank, "Unranked").to_title_case(); let max_rank = unwrap_or_ref(&user.max_rank, "Unranked").to_title_case(); let rating = user.rating.unwrap_or(1500); @@ -60,7 +60,7 @@ pub fn user_embed<'a>(user: &User) -> CreateEmbed { } /// Gets an embed of the Rating Change. -pub fn rating_change_embed<'a>( +pub fn rating_change_embed( rating_change: &RatingChange, user: &User, contest: &Contest, diff --git a/youmubot-cf/src/hook.rs b/youmubot-cf/src/hook.rs index 483db33..e02f9cd 100644 --- a/youmubot-cf/src/hook.rs +++ b/youmubot-cf/src/hook.rs @@ -152,7 +152,7 @@ fn parse<'a>( matches } -fn print_info_message<'a>(info: &[(ContestOrProblem, &str)]) -> CreateEmbed { +fn print_info_message(info: &[(ContestOrProblem, &str)]) -> CreateEmbed { let (problems, contests): (Vec<_>, Vec<_>) = info.iter().partition(|(v, _)| match v { ContestOrProblem::Problem(_) => true, ContestOrProblem::Contest(_, _) => false, diff --git a/youmubot-core/src/community/mod.rs b/youmubot-core/src/community/mod.rs index 700448f..74e0f73 100644 --- a/youmubot-core/src/community/mod.rs +++ b/youmubot-core/src/community/mod.rs @@ -67,7 +67,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult let channel = m.channel_id.to_channel(&ctx).await?; if let Channel::Guild(channel) = channel { Ok(channel - .members(&ctx)? + .members(ctx)? .into_iter() .filter(|v| !v.user.bot) // Filter out bots .filter(|v| { diff --git a/youmubot-osu/src/discord/embeds.rs b/youmubot-osu/src/discord/embeds.rs index 667a44c..69b010b 100644 --- a/youmubot-osu/src/discord/embeds.rs +++ b/youmubot-osu/src/discord/embeds.rs @@ -144,12 +144,7 @@ fn beatmap_title( .build() } -pub fn beatmap_embed<'a>( - b: &'_ Beatmap, - m: Mode, - mods: Mods, - info: BeatmapInfoWithPP, -) -> CreateEmbed { +pub fn beatmap_embed(b: &'_ Beatmap, m: Mode, mods: Mods, info: BeatmapInfoWithPP) -> CreateEmbed { let diff = b.difficulty.apply_mods(mods, info.0.stars); CreateEmbed::new() .title(beatmap_title(&b.artist, &b.title, &b.difficulty_name, mods)) @@ -178,7 +173,7 @@ pub fn beatmap_embed<'a>( const MAX_DIFFS: usize = 25 - 4; -pub fn beatmapset_embed<'a>(bs: &'_ [Beatmap], m: Option) -> CreateEmbed { +pub fn beatmapset_embed(bs: &'_ [Beatmap], m: Option) -> CreateEmbed { let too_many_diffs = bs.len() > MAX_DIFFS; let b: &Beatmap = &bs[0]; let mut m = CreateEmbed::new() @@ -266,7 +261,7 @@ pub(crate) fn score_embed<'a>( impl<'a> ScoreEmbedBuilder<'a> { #[allow(clippy::many_single_char_names)] - pub fn build<'b>(&mut self) -> CreateEmbed { + pub fn build(&mut self) -> CreateEmbed { let mode = self.bm.mode(); let b = &self.bm.0; let s = self.s; diff --git a/youmubot-osu/src/discord/mod.rs b/youmubot-osu/src/discord/mod.rs index 93c27df..04ad7d7 100644 --- a/youmubot-osu/src/discord/mod.rs +++ b/youmubot-osu/src/discord/mod.rs @@ -246,7 +246,7 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult let reaction = reply.react(&ctx, '👌').await?; let completed = loop { let emoji = reaction.emoji.clone(); - let user_reaction = collector::ReactionCollector::new(&ctx) + let user_reaction = collector::ReactionCollector::new(ctx) .message_id(reply.id) .author_id(msg.author.id) .filter(move |r| r.emoji == emoji) diff --git a/youmubot-prelude/src/announcer.rs b/youmubot-prelude/src/announcer.rs index 1d6c101..fc51038 100644 --- a/youmubot-prelude/src/announcer.rs +++ b/youmubot-prelude/src/announcer.rs @@ -35,7 +35,7 @@ impl CacheHttp for CacheAndHttp { Some(&self.0) } fn http(&self) -> &Http { - &*self.1 + &self.1 } }