From 74edb888f3261bd39dacda73e4b39e1ecdc18fb4 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 14fa2645f41..37327fc4c38 100644 --- a/src/model/application.rs +++ b/src/model/application.rs @@ -67,7 +67,8 @@ pub struct TeamMember { pub user: User, } -#[derive(Clone, Debug, Copy, PartialEq)] +#[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 26137dac695..03e22773476 100644 --- a/src/model/application/command.rs +++ b/src/model/application/command.rs @@ -263,7 +263,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 { @@ -335,7 +335,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 { @@ -416,7 +416,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 491f99042d3..6ac7dbf4e8d 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 { @@ -173,7 +173,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 2b2713d0fea..47c4c35a9f0 100644 --- a/src/model/application/interaction/mod.rs +++ b/src/model/application/interaction/mod.rs @@ -173,7 +173,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 cb66552908c..733f839794b 100644 --- a/src/model/connection.rs +++ b/src/model/connection.rs @@ -30,7 +30,7 @@ pub struct Connection { } /// The visibility of a user connection on a user's profile. -#[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 1e7fb82a9ff..3cef87c9373 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -334,7 +334,7 @@ pub struct ActivityEmoji { pub animated: Option, } -#[derive(Clone, Copy, Debug, PartialEq)] +#[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 b6a684100be..888cdc5988e 100644 --- a/src/model/guild/integration.rs +++ b/src/model/guild/integration.rs @@ -26,7 +26,7 @@ pub struct Integration { } /// The behavior once the integration expires. -#[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 eb41bd83b5f..1dbced88297 100644 --- a/src/model/guild/premium_tier.rs +++ b/src/model/guild/premium_tier.rs @@ -1,5 +1,5 @@ /// The guild's premium tier, depends on the amount of users boosting the guild currently -#[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 fcd147a073c..43e4492e90a 100644 --- a/src/model/guild/scheduled_event.rs +++ b/src/model/guild/scheduled_event.rs @@ -46,7 +46,8 @@ pub struct ScheduledEvent { pub image: Option, } -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[non_exhaustive] pub enum ScheduledEventStatus { Scheduled = 1, Active = 2, @@ -62,7 +63,8 @@ enum_number!(ScheduledEventStatus { Canceled, }); -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[non_exhaustive] pub enum ScheduledEventType { StageInstance = 1, Voice = 2,