diff --git a/feather/base/src/anvil/level.rs b/feather/base/src/anvil/level.rs index b312e5de3..5411093a4 100644 --- a/feather/base/src/anvil/level.rs +++ b/feather/base/src/anvil/level.rs @@ -149,7 +149,7 @@ pub struct SuperflatLayer { } /// The type of world generator for a level. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum LevelGeneratorType { Default, Flat, diff --git a/feather/blocks/generator/src/load.rs b/feather/blocks/generator/src/load.rs index 10bd98909..390e0bbee 100644 --- a/feather/blocks/generator/src/load.rs +++ b/feather/blocks/generator/src/load.rs @@ -133,7 +133,7 @@ impl PropertyStore { fn update_name(name: &str) -> &str { match NAME_OVERRIDES.get(&name) { - Some(x) => *x, + Some(x) => x, None => name, } } diff --git a/feather/common/src/block_break.rs b/feather/common/src/block_break.rs index 9f3b919b1..4a7adaf3a 100644 --- a/feather/common/src/block_break.rs +++ b/feather/common/src/block_break.rs @@ -180,29 +180,16 @@ impl ActiveBreaker { .iter() .find_map(|(item, speed)| { equipped_item - .map(|e| { - if e.item() == *item { - Some(*speed) - } else { - None - } + .and_then(|e| { + bool::then_some(e.item() == *item, *speed) }) - .flatten() }) .unwrap_or(1.0); let effi_level = equipped_item - .map(ItemStack::metadata) - .flatten() - .map(|meta| { - meta.enchantments().iter().find_map(|ench| { - if ench.kind() == EnchantmentKind::Efficiency { - Some(ench.level()) - } else { - None - } - }) - }) - .flatten(); + .and_then(ItemStack::metadata) + .and_then(|meta| { + meta.get_enchantment_level(EnchantmentKind::Efficiency) + }); let effi_speed = effi_level.map(|level| level * level + 1).unwrap_or(0) as f32; let damage = if harvestable { (dig_multiplier + effi_speed) / block.hardness() / 30.0 diff --git a/feather/datapacks/src/id.rs b/feather/datapacks/src/id.rs index e0e9beebb..7f6213385 100644 --- a/feather/datapacks/src/id.rs +++ b/feather/datapacks/src/id.rs @@ -32,7 +32,7 @@ impl NamespacedId { } /// Error returned when a namespaced ID was formatted incorrectly. -#[derive(Debug, thiserror::Error, PartialEq)] +#[derive(Debug, thiserror::Error, PartialEq, Eq)] pub enum ParseError { #[error("'{0}' is not a valid character for namespaces")] InvalidNamespaceChar(char), diff --git a/feather/protocol/src/io.rs b/feather/protocol/src/io.rs index 4c9a51be6..fbe598fd0 100644 --- a/feather/protocol/src/io.rs +++ b/feather/protocol/src/io.rs @@ -480,7 +480,7 @@ impl<'a> Readable for LengthInferredVecU8<'a> { impl<'a> Writeable for LengthInferredVecU8<'a> { fn write(&self, buffer: &mut Vec, _version: ProtocolVersion) -> anyhow::Result<()> { - buffer.extend_from_slice(&*self.0); + buffer.extend_from_slice(&self.0); Ok(()) } } diff --git a/feather/server/src/initial_handler/proxy.rs b/feather/server/src/initial_handler/proxy.rs index f2a2775bb..4a590b036 100644 --- a/feather/server/src/initial_handler/proxy.rs +++ b/feather/server/src/initial_handler/proxy.rs @@ -10,7 +10,7 @@ mod bungeecord; mod velocity; /// IP forwarding data received from the proxy. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ProxyData { /// IP address of the proxy. pub host: String, diff --git a/feather/server/src/packet_handlers/interaction.rs b/feather/server/src/packet_handlers/interaction.rs index 01ef51425..f17671f6c 100644 --- a/feather/server/src/packet_handlers/interaction.rs +++ b/feather/server/src/packet_handlers/interaction.rs @@ -134,7 +134,7 @@ pub fn handle_player_digging( let hotbar_slot = game.ecs.get::(player)?.get(); let main_hand = window.item(SLOT_HOTBAR_OFFSET + hotbar_slot)?; *breaker = BlockBreaker::Active( - ActiveBreaker::new(&mut game.world, packet.position, main_hand.item_stack()) + ActiveBreaker::new(&mut game.world, packet.position, main_hand.option_ref()) .unwrap(), ); } diff --git a/feather/server/src/packet_handlers/inventory.rs b/feather/server/src/packet_handlers/inventory.rs index 48a397197..f8723b51c 100644 --- a/feather/server/src/packet_handlers/inventory.rs +++ b/feather/server/src/packet_handlers/inventory.rs @@ -56,7 +56,7 @@ pub fn handle_click_window( } client.set_cursor_slot(window.cursor_item()); - client.send_window_items(&*window); + client.send_window_items(&window); result } diff --git a/libcraft/items/src/item_stack.rs b/libcraft/items/src/item_stack.rs index fe227964a..09fc7c142 100644 --- a/libcraft/items/src/item_stack.rs +++ b/libcraft/items/src/item_stack.rs @@ -352,6 +352,7 @@ impl ItemStack { self.item.stack_size() } + #[must_use] pub fn metadata(&self) -> Option<&ItemStackMeta> { self.meta.as_ref() } @@ -403,9 +404,11 @@ impl ItemStackMeta { self.enchantments.push(Enchantment::new(ench, level)); } } + #[must_use] pub fn enchantments(&self) -> &[Enchantment] { &self.enchantments } + #[must_use] pub fn enchantments_mut(&mut self) -> &mut Vec { &mut self.enchantments } diff --git a/libcraft/text/src/text.rs b/libcraft/text/src/text.rs index 90af776de..ea5108e3f 100644 --- a/libcraft/text/src/text.rs +++ b/libcraft/text/src/text.rs @@ -16,7 +16,7 @@ pub enum TextConversionError { InvalidStyle(String), } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum Color { DarkRed, @@ -304,7 +304,7 @@ where } } -impl<'a> From<&Translate> for String { +impl From<&Translate> for String { fn from(translate: &Translate) -> Self { match translate { Translate::ChatTypeText => "chat.type.text", diff --git a/libcraft/text/src/text/markdown/lexer.rs b/libcraft/text/src/text/markdown/lexer.rs index 27e003e3b..899357bc8 100644 --- a/libcraft/text/src/text/markdown/lexer.rs +++ b/libcraft/text/src/text/markdown/lexer.rs @@ -13,7 +13,7 @@ use std::slice::Iter; pub type Span<'a> = LocatedSpan<&'a str>; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct LexToken<'a> { pub tok: LexTokenType<'a>, pub span: Span<'a>, @@ -34,7 +34,7 @@ pub enum LexTokenType<'a> { Word(&'a str), } -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct Tokens<'a> { pub tok: &'a [LexToken<'a>], start: usize, @@ -159,7 +159,7 @@ pub fn lex_control_word(input: Span) -> IResult IResult> { map(space1, |s: Span| { - LexToken::new(s, LexTokenType::Space(*s.fragment())) + LexToken::new(s, LexTokenType::Space(s.fragment())) })(input) } @@ -173,13 +173,13 @@ pub fn valid_word(input: Span) -> IResult> { pub fn lex_word(input: Span) -> IResult> { map(valid_word, |s: Span| { - LexToken::new(s, LexTokenType::Word(*s.fragment())) + LexToken::new(s, LexTokenType::Word(s.fragment())) })(input) } pub fn lex_color_code(input: Span) -> IResult> { map(preceded(peek(tag("#")), take(7usize)), |code: Span| { - LexToken::new(code, LexTokenType::Word(*code.fragment())) + LexToken::new(code, LexTokenType::Word(code.fragment())) })(input) } diff --git a/libcraft/text/src/text/markdown/parser.rs b/libcraft/text/src/text/markdown/parser.rs index 60ba2d9c5..52ed26bd4 100644 --- a/libcraft/text/src/text/markdown/parser.rs +++ b/libcraft/text/src/text/markdown/parser.rs @@ -9,7 +9,7 @@ use nom::{Err, IResult}; pub mod events; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct DynamicSpan { pub fragment: String, pub col: usize, diff --git a/libcraft/text/src/text/markdown/parser/events.rs b/libcraft/text/src/text/markdown/parser/events.rs index 73932a840..d3e933318 100644 --- a/libcraft/text/src/text/markdown/parser/events.rs +++ b/libcraft/text/src/text/markdown/parser/events.rs @@ -4,13 +4,13 @@ pub enum EventParseError<'a> { InvalidEventAction(&'a str), } -#[derive(Debug, PartialEq, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum EventType { OnHover, OnClick, } -#[derive(Debug, PartialEq, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum EventAction { ShowText, OpenUrl, diff --git a/quill/api/src/setup.rs b/quill/api/src/setup.rs index 0b555b25f..07fdebf96 100644 --- a/quill/api/src/setup.rs +++ b/quill/api/src/setup.rs @@ -24,6 +24,7 @@ impl Setup { /// /// The function should take as parameters your /// plugin instance and an `&mut Game` and return nothing. + #[allow(clippy::type_complexity)] pub fn add_system(&mut self, system: T) -> &mut Self { let system: Box = Box::new(system); let system_data = Box::leak(Box::new(system)) as *mut Box<_> as *mut u8; diff --git a/quill/common/src/components.rs b/quill/common/src/components.rs index 352c45b69..b0fecea22 100644 --- a/quill/common/src/components.rs +++ b/quill/common/src/components.rs @@ -45,7 +45,7 @@ impl Name { } pub fn as_str(&self) -> &str { - &*self + self } } @@ -73,7 +73,7 @@ impl CustomName { } pub fn as_str(&self) -> &str { - &*self + self } pub fn as_mut_str(&mut self) -> &mut str { diff --git a/quill/plugin-format/src/lib.rs b/quill/plugin-format/src/lib.rs index 20a55c417..0c7ae0c53 100644 --- a/quill/plugin-format/src/lib.rs +++ b/quill/plugin-format/src/lib.rs @@ -43,7 +43,7 @@ impl<'a> PluginFile<'a> { /// this is the contents of the shared library /// containing the plugin. pub fn module(&self) -> &[u8] { - &*self.module + &self.module } pub fn metadata(&self) -> &PluginMetadata { diff --git a/quill/plugin-format/src/metadata.rs b/quill/plugin-format/src/metadata.rs index 66cd70eb5..b72b3e1a7 100644 --- a/quill/plugin-format/src/metadata.rs +++ b/quill/plugin-format/src/metadata.rs @@ -3,7 +3,7 @@ use serde_with::{serde_as, DisplayFromStr}; use target_lexicon::Triple; /// A plugin's metadata, stored alongside its WASM module. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct PluginMetadata { /// Plugin name, no spaces pub name: String,