Skip to content

Commit bbfd69b

Browse files
committed
Make clippy happy
1 parent f9f5b6f commit bbfd69b

File tree

17 files changed

+31
-40
lines changed

17 files changed

+31
-40
lines changed

feather/base/src/anvil/level.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub struct SuperflatLayer {
149149
}
150150

151151
/// The type of world generator for a level.
152-
#[derive(Debug, PartialEq)]
152+
#[derive(Debug, PartialEq, Eq)]
153153
pub enum LevelGeneratorType {
154154
Default,
155155
Flat,

feather/blocks/generator/src/load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl PropertyStore {
133133

134134
fn update_name(name: &str) -> &str {
135135
match NAME_OVERRIDES.get(&name) {
136-
Some(x) => *x,
136+
Some(x) => x,
137137
None => name,
138138
}
139139
}

feather/common/src/block_break.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,16 @@ impl ActiveBreaker {
180180
.iter()
181181
.find_map(|(item, speed)| {
182182
equipped_item
183-
.map(|e| {
184-
if e.item() == *item {
185-
Some(*speed)
186-
} else {
187-
None
188-
}
183+
.and_then(|e| {
184+
bool::then_some(e.item() == *item, *speed)
189185
})
190-
.flatten()
191186
})
192187
.unwrap_or(1.0);
193188
let effi_level = equipped_item
194-
.map(ItemStack::metadata)
195-
.flatten()
196-
.map(|meta| {
197-
meta.enchantments().iter().find_map(|ench| {
198-
if ench.kind() == EnchantmentKind::Efficiency {
199-
Some(ench.level())
200-
} else {
201-
None
202-
}
203-
})
204-
})
205-
.flatten();
189+
.and_then(ItemStack::metadata)
190+
.and_then(|meta| {
191+
meta.get_enchantment_level(EnchantmentKind::Efficiency)
192+
});
206193
let effi_speed = effi_level.map(|level| level * level + 1).unwrap_or(0) as f32;
207194
let damage = if harvestable {
208195
(dig_multiplier + effi_speed) / block.hardness() / 30.0

feather/datapacks/src/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl NamespacedId {
3232
}
3333

3434
/// Error returned when a namespaced ID was formatted incorrectly.
35-
#[derive(Debug, thiserror::Error, PartialEq)]
35+
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
3636
pub enum ParseError {
3737
#[error("'{0}' is not a valid character for namespaces")]
3838
InvalidNamespaceChar(char),

feather/protocol/src/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<'a> Readable for LengthInferredVecU8<'a> {
480480

481481
impl<'a> Writeable for LengthInferredVecU8<'a> {
482482
fn write(&self, buffer: &mut Vec<u8>, _version: ProtocolVersion) -> anyhow::Result<()> {
483-
buffer.extend_from_slice(&*self.0);
483+
buffer.extend_from_slice(&self.0);
484484
Ok(())
485485
}
486486
}

feather/server/src/initial_handler/proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod bungeecord;
1010
mod velocity;
1111

1212
/// IP forwarding data received from the proxy.
13-
#[derive(Debug, PartialEq)]
13+
#[derive(Debug, PartialEq, Eq)]
1414
pub struct ProxyData {
1515
/// IP address of the proxy.
1616
pub host: String,

feather/server/src/packet_handlers/interaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn handle_player_digging(
134134
let hotbar_slot = game.ecs.get::<HotbarSlot>(player)?.get();
135135
let main_hand = window.item(SLOT_HOTBAR_OFFSET + hotbar_slot)?;
136136
*breaker = BlockBreaker::Active(
137-
ActiveBreaker::new(&mut game.world, packet.position, main_hand.item_stack())
137+
ActiveBreaker::new(&mut game.world, packet.position, main_hand.option_ref())
138138
.unwrap(),
139139
);
140140
}

feather/server/src/packet_handlers/inventory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn handle_click_window(
5656
}
5757
client.set_cursor_slot(window.cursor_item());
5858

59-
client.send_window_items(&*window);
59+
client.send_window_items(&window);
6060

6161
result
6262
}

libcraft/items/src/item_stack.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ impl ItemStack {
352352
self.item.stack_size()
353353
}
354354

355+
#[must_use]
355356
pub fn metadata(&self) -> Option<&ItemStackMeta> {
356357
self.meta.as_ref()
357358
}
@@ -403,9 +404,11 @@ impl ItemStackMeta {
403404
self.enchantments.push(Enchantment::new(ench, level));
404405
}
405406
}
407+
#[must_use]
406408
pub fn enchantments(&self) -> &[Enchantment] {
407409
&self.enchantments
408410
}
411+
#[must_use]
409412
pub fn enchantments_mut(&mut self) -> &mut Vec<Enchantment> {
410413
&mut self.enchantments
411414
}

libcraft/text/src/text.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum TextConversionError {
1616
InvalidStyle(String),
1717
}
1818

19-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2020
#[serde(rename_all = "snake_case")]
2121
pub enum Color {
2222
DarkRed,
@@ -304,7 +304,7 @@ where
304304
}
305305
}
306306

307-
impl<'a> From<&Translate> for String {
307+
impl From<&Translate> for String {
308308
fn from(translate: &Translate) -> Self {
309309
match translate {
310310
Translate::ChatTypeText => "chat.type.text",

0 commit comments

Comments
 (0)