Skip to content

Commit

Permalink
Fix clippy warning on next (serenity-rs#3078)
Browse files Browse the repository at this point in the history
Fixes CI failure
  • Loading branch information
mkrasnitski committed Dec 8, 2024
1 parent 26fc4b2 commit f7daa0f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ make_specific_collector!(
// - filter expression (this expressoin must return true to let the event through)
author_id: UserId => interaction.user.id == *author_id,
channel_id: ChannelId => interaction.channel_id == *channel_id,
guild_id: GuildId => interaction.guild_id.map_or(true, |x| x == *guild_id),
guild_id: GuildId => interaction.guild_id.is_none_or(|x| x == *guild_id),
message_id: MessageId => interaction.message.id == *message_id,
custom_ids: FixedArray<FixedString> => custom_ids.contains(&interaction.data.custom_id),
);
Expand All @@ -190,17 +190,17 @@ make_specific_collector!(
}) => interaction,
author_id: UserId => interaction.user.id == *author_id,
channel_id: ChannelId => interaction.channel_id == *channel_id,
guild_id: GuildId => interaction.guild_id.map_or(true, |g| g == *guild_id),
message_id: MessageId => interaction.message.as_ref().map_or(true, |m| m.id == *message_id),
guild_id: GuildId => interaction.guild_id.is_none_or(|g| g == *guild_id),
message_id: MessageId => interaction.message.as_ref().is_none_or(|m| m.id == *message_id),
custom_ids: Vec<FixedString> => custom_ids.contains(&interaction.data.custom_id),
);
make_specific_collector!(
ReactionCollector, Reaction,
CollectReactions, collect_reactions,
Event::ReactionAdd(ReactionAddEvent { reaction }) => reaction,
author_id: UserId => reaction.user_id.map_or(true, |a| a == *author_id),
author_id: UserId => reaction.user_id.is_none_or(|a| a == *author_id),
channel_id: ChannelId => reaction.channel_id == *channel_id,
guild_id: GuildId => reaction.guild_id.map_or(true, |g| g == *guild_id),
guild_id: GuildId => reaction.guild_id.is_none_or(|g| g == *guild_id),
message_id: MessageId => reaction.message_id == *message_id,
);
make_specific_collector!(
Expand All @@ -209,5 +209,5 @@ make_specific_collector!(
Event::MessageCreate(MessageCreateEvent { message }) => message,
author_id: UserId => message.author.id == *author_id,
channel_id: ChannelId => message.channel_id == *channel_id,
guild_id: GuildId => message.guild_id.map_or(true, |g| g == *guild_id),
guild_id: GuildId => message.guild_id.is_none_or(|g| g == *guild_id),
);
2 changes: 1 addition & 1 deletion src/gateway/sharding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ impl Shard {
}

let resume = num
.map_or(true, |x| x != close_codes::AUTHENTICATION_FAILED && self.session_id.is_some());
.is_none_or(|x| x != close_codes::AUTHENTICATION_FAILED && self.session_id.is_some());

Ok(Some(if resume {
ShardAction::Reconnect(ReconnectType::Resume)
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/sharding/shard_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ impl ShardRunner {
let can_dispatch = self
.event_handler
.as_ref()
.map_or(true, |handler| handler.filter_event(&context, &event))
.is_none_or(|handler| handler.filter_event(&context, &event))
&& self
.raw_event_handler
.as_ref()
.map_or(true, |handler| handler.filter_event(&context, &event));
.is_none_or(|handler| handler.filter_event(&context, &event));

if can_dispatch {
#[cfg(feature = "collector")]
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ impl Guild {

for member in &self.members {
if &*member.user.name == username
&& discrim.map_or(true, |d| member.user.discriminator == d)
&& discrim.is_none_or(|d| member.user.discriminator == d)
{
return Some(member);
}
Expand Down

0 comments on commit f7daa0f

Please sign in to comment.