Skip to content

Commit 2f99d76

Browse files
authored
Apply 1.60 clippy lints and apply variable name (#544)
* FIx clippy 1.60 lints * cargo fmt
1 parent 67bc206 commit 2f99d76

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

feather/base/src/anvil/player.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,17 @@ pub struct InventorySlot {
7171

7272
impl InventorySlot {
7373
/// Converts an [`ItemStack`] and network protocol index into an [`InventorySlot`].
74-
pub fn from_network_index(network: usize, stack: &ItemStack) -> Option<Self> {
75-
let slot = if SLOT_HOTBAR_OFFSET <= network && network < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
74+
#[allow(clippy::manual_range_contains)]
75+
pub fn from_network_index(index: usize, stack: &ItemStack) -> Option<Self> {
76+
let slot = if SLOT_HOTBAR_OFFSET <= index && index < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
7677
// Hotbar
77-
(network - SLOT_HOTBAR_OFFSET) as i8
78-
} else if network == SLOT_OFFHAND {
78+
(index - SLOT_HOTBAR_OFFSET) as i8
79+
} else if index == SLOT_OFFHAND {
7980
-106
80-
} else if SLOT_ARMOR_MIN <= network && network <= SLOT_ARMOR_MAX {
81-
((SLOT_ARMOR_MAX - network) + 100) as i8
82-
} else if SLOT_INVENTORY_OFFSET <= network
83-
&& network < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE
84-
{
85-
network as i8
81+
} else if SLOT_ARMOR_MIN <= index && index <= SLOT_ARMOR_MAX {
82+
((SLOT_ARMOR_MAX - index) + 100) as i8
83+
} else if SLOT_INVENTORY_OFFSET <= index && index < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE {
84+
index as i8
8685
} else {
8786
return None;
8887
};

feather/worldgen/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ impl NearbyBiomes {
340340
let chunk_x = (x / 16) as usize;
341341
let chunk_z = (z / 16) as usize;
342342

343-
let mut local_x = (ox % 16).abs() as usize;
344-
let local_y = (oy % 16).abs() as usize;
345-
let mut local_z = (oz % 16).abs() as usize;
343+
let mut local_x = (ox % 16).unsigned_abs();
344+
let local_y = (oy % 16).unsigned_abs();
345+
let mut local_z = (oz % 16).unsigned_abs();
346346

347347
if ox < 0 {
348348
local_x = 16 - local_x;

libcraft/items/src/item_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub enum ItemStackError {
366366

367367
impl Display for ItemStackError {
368368
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
369-
write!(f, "{}", self)
369+
write!(f, "{:?}", self)
370370
}
371371
}
372372

0 commit comments

Comments
 (0)