Skip to content

Commit

Permalink
Fix clippy::assigning_clones (#2784)
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev authored Mar 8, 2024
1 parent a51ad24 commit 702fb87
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/cache/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,9 @@ impl CacheUpdate for VoiceChannelStatusUpdateEvent {
fn update(&mut self, cache: &Cache) -> Option<Self::Output> {
if let Some(mut channel) = cache.channel_mut(self.id) {
let old = channel.status.clone();
channel.status = self.status.clone();
channel.status.clone_from(&self.status);
// Discord updates topic but doesn't fire ChannelUpdate.
channel.topic = self.status.clone();
channel.topic.clone_from(&self.status);
old
} else {
None
Expand Down
51 changes: 25 additions & 26 deletions src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ pub struct MessageUpdateEvent {
}

impl MessageUpdateEvent {
#[allow(clippy::clone_on_copy)] // For consistency between fields
#[rustfmt::skip]
/// Writes the updated data in this message update event into the given [`Message`].
pub fn apply_to_message(&self, message: &mut Message) {
Expand Down Expand Up @@ -587,36 +586,36 @@ impl MessageUpdateEvent {
// a self-constructed MessageUpdateEvent that does change these fields.
message.id = *id;
message.channel_id = *channel_id;
message.guild_id = *guild_id;
message.edited_timestamp = *edited_timestamp;

if let Some(x) = author { message.author = x.clone() }
if let Some(x) = content { message.content = x.clone() }
if let Some(x) = timestamp { message.timestamp = x.clone() }
message.edited_timestamp = *edited_timestamp;
if let Some(x) = content { message.content.clone_from(x) }
if let Some(x) = timestamp { message.timestamp = *x }
if let Some(x) = tts { message.set_tts(*x) }
if let Some(x) = mention_everyone { message.set_mention_everyone(*x) }
if let Some(x) = mentions { message.mentions = x.clone() }
if let Some(x) = mention_roles { message.mention_roles = x.clone() }
if let Some(x) = mention_channels { message.mention_channels = x.clone() }
if let Some(x) = attachments { message.attachments = x.clone() }
if let Some(x) = embeds { message.embeds = x.clone() }
if let Some(x) = reactions { message.reactions = x.clone() }
if let Some(x) = mentions { message.mentions.clone_from(x) }
if let Some(x) = mention_roles { message.mention_roles.clone_from(x) }
if let Some(x) = mention_channels { message.mention_channels.clone_from(x) }
if let Some(x) = attachments { message.attachments.clone_from(x) }
if let Some(x) = embeds { message.embeds.clone_from(x) }
if let Some(x) = reactions { message.reactions.clone_from(x) }
if let Some(x) = pinned { message.set_pinned(*x) }
if let Some(x) = webhook_id { message.webhook_id = x.clone() }
if let Some(x) = kind { message.kind = x.clone() }
if let Some(x) = activity { message.activity = x.clone() }
if let Some(x) = application { message.application = x.clone() }
if let Some(x) = application_id { message.application_id = x.clone() }
if let Some(x) = message_reference { message.message_reference = x.clone() }
if let Some(x) = flags { message.flags = x.clone() }
if let Some(x) = referenced_message { message.referenced_message = x.clone() }
if let Some(x) = interaction { message.interaction = x.clone() }
if let Some(x) = thread { message.thread = x.clone() }
if let Some(x) = components { message.components = x.clone() }
if let Some(x) = sticker_items { message.sticker_items = x.clone() }
if let Some(x) = position { message.position = x.clone() }
if let Some(x) = role_subscription_data { message.role_subscription_data = x.clone() }
message.guild_id = *guild_id;
if let Some(x) = member { message.member = x.clone() }
if let Some(x) = webhook_id { message.webhook_id.clone_from(x) }
if let Some(x) = kind { message.kind = *x }
if let Some(x) = activity { message.activity.clone_from(x) }
if let Some(x) = application { message.application.clone_from(x) }
if let Some(x) = application_id { message.application_id.clone_from(x) }
if let Some(x) = message_reference { message.message_reference.clone_from(x) }
if let Some(x) = flags { message.flags.clone_from(x) }
if let Some(x) = referenced_message { message.referenced_message.clone_from(x) }
if let Some(x) = interaction { message.interaction.clone_from(x) }
if let Some(x) = thread { message.thread.clone_from(x) }
if let Some(x) = components { message.components.clone_from(x) }
if let Some(x) = sticker_items { message.sticker_items.clone_from(x) }
if let Some(x) = position { message.position.clone_from(x) }
if let Some(x) = role_subscription_data { message.role_subscription_data.clone_from(x) }
if let Some(x) = member { message.member.clone_from(x) }
}
}

Expand Down

0 comments on commit 702fb87

Please sign in to comment.