From ae4b1e85e669bc882d158509ef1eda46c6b2a72e Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 30 May 2025 19:36:59 -0800 Subject: fix clippy issues and improve formatting everywhere --- azalea-inventory/src/components.rs | 12 ++++++++---- azalea-inventory/src/slot.rs | 14 +++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'azalea-inventory/src') diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components.rs index 9e0a37b0..72216475 100644 --- a/azalea-inventory/src/components.rs +++ b/azalea-inventory/src/components.rs @@ -1,5 +1,9 @@ use core::f64; -use std::{any::Any, collections::HashMap, io::Cursor}; +use std::{ + any::Any, + collections::HashMap, + io::{self, Cursor}, +}; use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError}; use azalea_chat::FormattedText; @@ -23,11 +27,11 @@ pub trait DataComponent: Send + Sync + Any { } pub trait EncodableDataComponent: Send + Sync + Any { - fn encode(&self, buf: &mut Vec) -> Result<(), std::io::Error>; + fn encode(&self, buf: &mut Vec) -> io::Result<()>; // using the Clone trait makes it not be object-safe, so we have our own clone // function instead fn clone(&self) -> Box; - // same deal here + // same thing here fn eq(&self, other: Box) -> bool; } @@ -35,7 +39,7 @@ impl EncodableDataComponent for T where T: DataComponent + Clone + AzaleaWrite + AzaleaRead + PartialEq, { - fn encode(&self, buf: &mut Vec) -> Result<(), std::io::Error> { + fn encode(&self, buf: &mut Vec) -> io::Result<()> { self.azalea_write(buf) } fn clone(&self) -> Box { diff --git a/azalea-inventory/src/slot.rs b/azalea-inventory/src/slot.rs index e2e84a68..c48d9488 100644 --- a/azalea-inventory/src/slot.rs +++ b/azalea-inventory/src/slot.rs @@ -1,7 +1,7 @@ use std::{ any::Any, fmt, - io::{Cursor, Write}, + io::{self, Cursor, Write}, }; use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError}; @@ -73,10 +73,10 @@ impl ItemStack { /// Update whether this slot is empty, based on the count. pub fn update_empty(&mut self) { - if let ItemStack::Present(i) = self { - if i.is_empty() { - *self = ItemStack::Empty; - } + if let ItemStack::Present(i) = self + && i.is_empty() + { + *self = ItemStack::Empty; } } @@ -159,7 +159,7 @@ impl AzaleaRead for ItemStack { } impl AzaleaWrite for ItemStack { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { match self { ItemStack::Empty => 0_i32.azalea_write_var(buf)?, ItemStack::Present(i) => { @@ -256,7 +256,7 @@ impl AzaleaRead for DataComponentPatch { } impl AzaleaWrite for DataComponentPatch { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { let mut components_with_data_count: u32 = 0; let mut components_without_data_count: u32 = 0; for component in self.components.values() { -- cgit v1.2.3