From f74c4d62c21cba6d6b8fd7242164f83650ac5f6d Mon Sep 17 00:00:00 2001 From: nickelc Date: Tue, 21 Jun 2022 10:01:43 +0200 Subject: [PATCH] Unify `derive` & `#[non_exhaustive]` attributes for number enums (#1999) BREAKING CHANGE: Some enums were missing the `[non_exhaustive]` attribute. --- src/model/application.rs | 3 ++- src/model/application/command.rs | 6 +++--- src/model/application/component.rs | 6 +++--- src/model/application/interaction/mod.rs | 2 +- src/model/connection.rs | 2 +- src/model/gateway.rs | 2 +- src/model/guild/integration.rs | 2 +- src/model/guild/premium_tier.rs | 2 +- src/model/guild/scheduled_event.rs | 6 ++++-- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/model/application.rs b/src/model/application.rs index 231d023868c..77738bfa99c 100644 --- a/src/model/application.rs +++ b/src/model/application.rs @@ -106,7 +106,8 @@ pub struct TeamMember { } /// [Discord docs](https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum). -#[derive(Clone, Debug, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[non_exhaustive] pub enum MembershipState { Invited = 1, Accepted = 2, diff --git a/src/model/application/command.rs b/src/model/application/command.rs index 80e1ef77bb6..8fa3e47d8ea 100644 --- a/src/model/application/command.rs +++ b/src/model/application/command.rs @@ -246,7 +246,7 @@ impl Command { /// The type of an application command. /// /// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum CommandType { @@ -324,7 +324,7 @@ pub struct CommandOption { /// The type of an [`CommandOption`]. /// /// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum CommandOptionType { @@ -405,7 +405,7 @@ pub struct CommandPermissionData { /// The type of an [`CommandPermissionData`]. /// /// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum CommandPermissionType { diff --git a/src/model/application/component.rs b/src/model/application/component.rs index 51033ef78c6..5f100ffe60a 100644 --- a/src/model/application/component.rs +++ b/src/model/application/component.rs @@ -7,7 +7,7 @@ use crate::model::channel::ReactionType; use crate::model::utils::deserialize_val; /// The type of a component -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum ComponentType { @@ -105,7 +105,7 @@ pub struct Button { } /// The style of a button. -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum ButtonStyle { @@ -176,7 +176,7 @@ pub struct InputText { } /// The style of the input text -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum InputTextStyle { diff --git a/src/model/application/interaction/mod.rs b/src/model/application/interaction/mod.rs index 19a527898bb..14fd09fe862 100644 --- a/src/model/application/interaction/mod.rs +++ b/src/model/application/interaction/mod.rs @@ -186,7 +186,7 @@ impl Serialize for Interaction { /// The type of an Interaction. /// /// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum InteractionType { diff --git a/src/model/connection.rs b/src/model/connection.rs index a93222be4f0..37a140a1cc9 100644 --- a/src/model/connection.rs +++ b/src/model/connection.rs @@ -36,7 +36,7 @@ pub struct Connection { /// The visibility of a user connection on a user's profile. /// /// [Discord docs](https://discord.com/developers/docs/resources/user#connection-object-visibility-types). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum ConnectionVisibility { diff --git a/src/model/gateway.rs b/src/model/gateway.rs index efa7634dbb0..6955c1db619 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -350,7 +350,7 @@ pub struct ActivityEmoji { } /// [Discord docs](https://discord.com/developers/docs/topics/gateway#activity-object-activity-types). -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] #[non_exhaustive] pub enum ActivityType { /// An indicator that the user is playing a game. diff --git a/src/model/guild/integration.rs b/src/model/guild/integration.rs index 07833274870..c6d4cc3d860 100644 --- a/src/model/guild/integration.rs +++ b/src/model/guild/integration.rs @@ -30,7 +30,7 @@ pub struct Integration { /// The behavior once the integration expires. /// /// [Discord docs](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors). -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] #[repr(u8)] pub enum IntegrationExpireBehaviour { diff --git a/src/model/guild/premium_tier.rs b/src/model/guild/premium_tier.rs index 17e76a2ba4b..9933e6d6784 100644 --- a/src/model/guild/premium_tier.rs +++ b/src/model/guild/premium_tier.rs @@ -1,7 +1,7 @@ /// The guild's premium tier, depends on the amount of users boosting the guild currently /// /// [Discord docs](https://discord.com/developers/docs/resources/guild#guild-object-premium-tier). -#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] #[non_exhaustive] pub enum PremiumTier { /// No tier, considered None diff --git a/src/model/guild/scheduled_event.rs b/src/model/guild/scheduled_event.rs index f34fba9320a..dd8b0ca1b78 100644 --- a/src/model/guild/scheduled_event.rs +++ b/src/model/guild/scheduled_event.rs @@ -49,7 +49,8 @@ pub struct ScheduledEvent { } /// [Discord docs](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status). -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[non_exhaustive] pub enum ScheduledEventStatus { Scheduled = 1, Active = 2, @@ -66,7 +67,8 @@ enum_number!(ScheduledEventStatus { }); /// [Discord docs](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types). -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[non_exhaustive] pub enum ScheduledEventType { StageInstance = 1, Voice = 2,