diff options
Diffstat (limited to 'azalea-core/src')
| -rw-r--r-- | azalea-core/src/bitset.rs | 4 | ||||
| -rw-r--r-- | azalea-core/src/difficulty.rs | 8 | ||||
| -rw-r--r-- | azalea-core/src/filterable.rs | 4 | ||||
| -rw-r--r-- | azalea-core/src/game_type.rs | 6 | ||||
| -rw-r--r-- | azalea-core/src/objectives.rs | 4 | ||||
| -rw-r--r-- | azalea-core/src/position.rs | 16 | ||||
| -rw-r--r-- | azalea-core/src/resource_location.rs | 4 |
7 files changed, 24 insertions, 22 deletions
diff --git a/azalea-core/src/bitset.rs b/azalea-core/src/bitset.rs index 715c57fb..ccc43ba0 100644 --- a/azalea-core/src/bitset.rs +++ b/azalea-core/src/bitset.rs @@ -1,4 +1,4 @@ -use std::io::{Cursor, Write}; +use std::io::{self, Cursor, Write}; use azalea_buf::{AzBuf, AzaleaRead, AzaleaWrite, BufReadError}; @@ -177,7 +177,7 @@ impl<const N: usize> AzaleaWrite for FixedBitSet<N> where [u8; bits_to_bytes(N)]: Sized, { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { for i in 0..bits_to_bytes(N) { self.data[i].azalea_write(buf)?; } diff --git a/azalea-core/src/difficulty.rs b/azalea-core/src/difficulty.rs index b907bbb3..f82f0e9d 100644 --- a/azalea-core/src/difficulty.rs +++ b/azalea-core/src/difficulty.rs @@ -1,6 +1,6 @@ use std::{ - fmt::{Debug, Error, Formatter}, - io::{Cursor, Write}, + fmt::{self, Debug}, + io::{self, Cursor, Write}, }; use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError}; @@ -18,7 +18,7 @@ pub enum Err { } impl Debug for Err { - fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Err::InvalidDifficulty(s) => write!(f, "Invalid difficulty: {s}"), } @@ -73,7 +73,7 @@ impl AzaleaRead for Difficulty { } impl AzaleaWrite for Difficulty { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { u8::azalea_write(&self.id(), buf) } } diff --git a/azalea-core/src/filterable.rs b/azalea-core/src/filterable.rs index 70b0d6f7..1c432b28 100644 --- a/azalea-core/src/filterable.rs +++ b/azalea-core/src/filterable.rs @@ -1,4 +1,4 @@ -use std::io::Cursor; +use std::io::{self, Cursor, Write}; use azalea_buf::{AzaleaRead, AzaleaReadLimited, AzaleaReadVar, AzaleaWrite}; @@ -9,7 +9,7 @@ pub struct Filterable<T> { } impl<T: AzaleaWrite> azalea_buf::AzaleaWrite for Filterable<T> { - fn azalea_write(&self, buf: &mut impl std::io::Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { self.raw.azalea_write(buf)?; self.filtered.azalea_write(buf)?; Ok(()) diff --git a/azalea-core/src/game_type.rs b/azalea-core/src/game_type.rs index 5d9ee8f5..7328902a 100644 --- a/azalea-core/src/game_type.rs +++ b/azalea-core/src/game_type.rs @@ -1,4 +1,4 @@ -use std::io::{Cursor, Write}; +use std::io::{self, Cursor, Write}; use azalea_buf::{AzaleaRead, AzaleaReadVar, AzaleaWrite, BufReadError}; use azalea_chat::translatable_component::TranslatableComponent; @@ -108,7 +108,7 @@ impl AzaleaRead for GameMode { } impl AzaleaWrite for GameMode { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { u8::azalea_write(&self.to_id(), buf) } } @@ -138,7 +138,7 @@ impl AzaleaRead for OptionalGameType { } impl AzaleaWrite for OptionalGameType { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { GameMode::to_optional_id(*self).azalea_write(buf) } } diff --git a/azalea-core/src/objectives.rs b/azalea-core/src/objectives.rs index a2f0d517..be5ea252 100644 --- a/azalea-core/src/objectives.rs +++ b/azalea-core/src/objectives.rs @@ -1,5 +1,5 @@ use std::{ - fmt::{self, Display, Formatter}, + fmt::{self, Display}, str::FromStr, }; @@ -12,7 +12,7 @@ pub enum ObjectiveCriteria { } impl Display for ObjectiveCriteria { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ObjectiveCriteria::Integer => write!(f, "integer"), ObjectiveCriteria::Hearts => write!(f, "hearts"), diff --git a/azalea-core/src/position.rs b/azalea-core/src/position.rs index e82e5e4a..ea3df79b 100644 --- a/azalea-core/src/position.rs +++ b/azalea-core/src/position.rs @@ -3,6 +3,8 @@ //! The most common ones are [`Vec3`] and [`BlockPos`], which are usually used //! for entity positions and block positions, respectively. +use std::hash::Hasher; +use std::io; use std::str::FromStr; use std::{ fmt, @@ -477,7 +479,7 @@ impl AzaleaRead for ChunkPos { } } impl AzaleaWrite for ChunkPos { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { u64::from(*self).azalea_write(buf)?; Ok(()) } @@ -485,7 +487,7 @@ impl AzaleaWrite for ChunkPos { impl Hash for ChunkPos { #[inline] - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: Hasher>(&self, state: &mut H) { // optimized hash that only calls hash once u64::from(*self).hash(state); } @@ -526,7 +528,7 @@ impl ChunkBlockPos { impl Hash for ChunkBlockPos { // optimized hash that only calls hash once #[inline] - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: Hasher>(&self, state: &mut H) { u64::from(*self).hash(state); } } @@ -570,7 +572,7 @@ impl Add<ChunkSectionBlockPos> for ChunkSectionPos { impl Hash for ChunkSectionBlockPos { // optimized hash that only calls hash once #[inline] - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: Hasher>(&self, state: &mut H) { u16::from(*self).hash(state); } } @@ -782,7 +784,7 @@ impl AzaleaRead for ChunkSectionPos { } impl AzaleaWrite for BlockPos { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { let mut val: u64 = 0; val |= ((self.x as u64) & PACKED_X_MASK) << X_OFFSET; val |= (self.y as u64) & PACKED_Y_MASK; @@ -792,7 +794,7 @@ impl AzaleaWrite for BlockPos { } impl AzaleaWrite for GlobalPos { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { ResourceLocation::azalea_write(&self.world, buf)?; BlockPos::azalea_write(&self.pos, buf)?; @@ -801,7 +803,7 @@ impl AzaleaWrite for GlobalPos { } impl AzaleaWrite for ChunkSectionPos { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { let long = (((self.x & 0x3FFFFF) as i64) << 42) | (self.y & 0xFFFFF) as i64 | (((self.z & 0x3FFFFF) as i64) << 20); diff --git a/azalea-core/src/resource_location.rs b/azalea-core/src/resource_location.rs index 0b21a43b..a4309035 100644 --- a/azalea-core/src/resource_location.rs +++ b/azalea-core/src/resource_location.rs @@ -2,7 +2,7 @@ use std::{ fmt, - io::{Cursor, Write}, + io::{self, Cursor, Write}, str::FromStr, }; @@ -67,7 +67,7 @@ impl AzaleaRead for ResourceLocation { } } impl AzaleaWrite for ResourceLocation { - fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> { + fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> { self.to_string().azalea_write(buf) } } |
