Skip to content

Commit

Permalink
Unify derive & #[non_exhaustive] attributes for number enums
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Some enums were missing the `[non_exhaustive]` attribute.
  • Loading branch information
nickelc committed Jun 21, 2022
1 parent 93125ca commit 6d7dc91
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/model/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/model/application/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/model/application/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/model/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ pub struct ActivityEmoji {
pub animated: Option<bool>,
}

#[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.
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/premium_tier.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/model/guild/scheduled_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ pub struct ScheduledEvent {
pub image: Option<String>,
}

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum ScheduledEventStatus {
Scheduled = 1,
Active = 2,
Expand All @@ -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,
Expand Down

0 comments on commit 6d7dc91

Please sign in to comment.