From a8e05c660059a19994b46a2949d1c79ca4b4d579 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 26 Aug 2024 18:49:17 +0200 Subject: fix clippy suggestions --- src/raw/types.rs | 60 ++++++++++++++------------------------------------------ 1 file changed, 15 insertions(+), 45 deletions(-) (limited to 'src/raw/types.rs') diff --git a/src/raw/types.rs b/src/raw/types.rs index ce22f5f..1bc3d08 100644 --- a/src/raw/types.rs +++ b/src/raw/types.rs @@ -7,7 +7,7 @@ use std::hash::Hash; /// The "friend or foe" enum. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum IFF { /// Green vs green, red vs red. Friend, @@ -16,18 +16,13 @@ pub enum IFF { /// Something very wrong happened. Unknown, /// Field is not used in this kind of event. + #[default] None, } -impl Default for IFF { - fn default() -> Self { - IFF::None - } -} - /// Combat result (physical) #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtResult { /// Good physical hit Normal, @@ -52,20 +47,16 @@ pub enum CbtResult { /// Hit was breakbar damage. Breakbar, /// Field is not used in this kind of event. + #[default] None, } -impl Default for CbtResult { - fn default() -> Self { - CbtResult::None - } -} - /// Combat activation #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtActivation { /// Field is not used in this kind of event. + #[default] None, /// Activation without quickness Normal, @@ -79,20 +70,15 @@ pub enum CbtActivation { Reset, } -impl Default for CbtActivation { - fn default() -> Self { - CbtActivation::None - } -} - /// Combat state change /// /// The referenced fields are of the [`CbtEvent`](struct.CbtEvent.html) /// struct. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtStateChange { /// Field is not used in this kind of event. + #[default] None, /// `src_agent` entered combat. /// @@ -213,17 +199,12 @@ pub enum CbtStateChange { BarrierUpdate, } -impl Default for CbtStateChange { - fn default() -> Self { - CbtStateChange::None - } -} - /// Combat buff remove type #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum CbtBuffRemove { /// Field is not used in this kind of event. + #[default] None, /// All stacks removed. All, @@ -237,12 +218,6 @@ pub enum CbtBuffRemove { Manual, } -impl Default for CbtBuffRemove { - fn default() -> Self { - CbtBuffRemove::None - } -} - /// Custom skill ids #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] @@ -257,9 +232,10 @@ pub enum CbtCustomSkill { /// Language #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, FromPrimitive)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, FromPrimitive)] pub enum Language { /// English. + #[default] Eng = 0, /// French. Fre = 2, @@ -269,12 +245,6 @@ pub enum Language { Spa = 4, } -impl Default for Language { - fn default() -> Self { - Language::Eng - } -} - /// Buff formula attributes. /// /// Variants prefixed with `Custom` are not native to the game client but rather variants added by @@ -402,7 +372,7 @@ impl Agent { /// Gadgets are entities spawned by some skills, like the "Binding Roots" /// spawned by Entangle. pub fn is_gadget(&self) -> bool { - self.is_elite == std::u32::MAX && (self.prof & 0xffff_0000) == 0xffff_0000 + self.is_elite == u32::MAX && (self.prof & 0xffff_0000) == 0xffff_0000 } /// Checks whether this agent is a character. @@ -410,12 +380,12 @@ impl Agent { /// Characters are entities like clones, pets, minions, spirits, but also /// minis. pub fn is_character(&self) -> bool { - self.is_elite == std::u32::MAX && (self.prof & 0xffff_0000) != 0xffff_0000 + self.is_elite == u32::MAX && (self.prof & 0xffff_0000) != 0xffff_0000 } /// Checks whether this agent is a player. pub fn is_player(&self) -> bool { - self.is_elite != std::u32::MAX + self.is_elite != u32::MAX } } -- cgit v1.2.3