Skip to content

Commit

Permalink
Apply 1.60 clippy lints and apply variable name (#544)
Browse files Browse the repository at this point in the history
* FIx clippy 1.60 lints

* cargo fmt
  • Loading branch information
FussballAndy authored Jun 17, 2022
1 parent 67bc206 commit 2f99d76
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
19 changes: 9 additions & 10 deletions feather/base/src/anvil/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,17 @@ pub struct InventorySlot {

impl InventorySlot {
/// Converts an [`ItemStack`] and network protocol index into an [`InventorySlot`].
pub fn from_network_index(network: usize, stack: &ItemStack) -> Option<Self> {
let slot = if SLOT_HOTBAR_OFFSET <= network && network < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
#[allow(clippy::manual_range_contains)]
pub fn from_network_index(index: usize, stack: &ItemStack) -> Option<Self> {
let slot = if SLOT_HOTBAR_OFFSET <= index && index < SLOT_HOTBAR_OFFSET + HOTBAR_SIZE {
// Hotbar
(network - SLOT_HOTBAR_OFFSET) as i8
} else if network == SLOT_OFFHAND {
(index - SLOT_HOTBAR_OFFSET) as i8
} else if index == SLOT_OFFHAND {
-106
} else if SLOT_ARMOR_MIN <= network && network <= SLOT_ARMOR_MAX {
((SLOT_ARMOR_MAX - network) + 100) as i8
} else if SLOT_INVENTORY_OFFSET <= network
&& network < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE
{
network as i8
} else if SLOT_ARMOR_MIN <= index && index <= SLOT_ARMOR_MAX {
((SLOT_ARMOR_MAX - index) + 100) as i8
} else if SLOT_INVENTORY_OFFSET <= index && index < SLOT_INVENTORY_OFFSET + INVENTORY_SIZE {
index as i8
} else {
return None;
};
Expand Down
6 changes: 3 additions & 3 deletions feather/worldgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ impl NearbyBiomes {
let chunk_x = (x / 16) as usize;
let chunk_z = (z / 16) as usize;

let mut local_x = (ox % 16).abs() as usize;
let local_y = (oy % 16).abs() as usize;
let mut local_z = (oz % 16).abs() as usize;
let mut local_x = (ox % 16).unsigned_abs();
let local_y = (oy % 16).unsigned_abs();
let mut local_z = (oz % 16).unsigned_abs();

if ox < 0 {
local_x = 16 - local_x;
Expand Down
2 changes: 1 addition & 1 deletion libcraft/items/src/item_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ pub enum ItemStackError {

impl Display for ItemStackError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
write!(f, "{:?}", self)
}
}

Expand Down

0 comments on commit 2f99d76

Please sign in to comment.