diff options
Diffstat (limited to 'azalea-inventory/src')
| -rw-r--r-- | azalea-inventory/src/components.rs | 12 | ||||
| -rw-r--r-- | azalea-inventory/src/slot.rs | 14 |
2 files changed, 15 insertions, 11 deletions
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<u8>) -> Result<(), std::io::Error>; + fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()>; // using the Clone trait makes it not be object-safe, so we have our own clone // function instead fn clone(&self) -> Box<dyn EncodableDataComponent>; - // same deal here + // same thing here fn eq(&self, other: Box<dyn EncodableDataComponent>) -> bool; } @@ -35,7 +39,7 @@ impl<T> EncodableDataComponent for T where T: DataComponent + Clone + AzaleaWrite + AzaleaRead + PartialEq, { - fn encode(&self, buf: &mut Vec<u8>) -> Result<(), std::io::Error> { + fn encode(&self, buf: &mut Vec<u8>) -> io::Result<()> { self.azalea_write(buf) } fn clone(&self) -> Box<dyn EncodableDataComponent> { 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() { |
