aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src/decode.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-08-24 20:00:44 -0500
committermat <github@matdoes.dev>2022-08-24 20:00:44 -0500
commit2a2e82efeb4e090abf9144b39be834972c7a0a4d (patch)
tree49dae22f5d706dcd2f1fa43b9d3aec7b15bac328 /azalea-nbt/src/decode.rs
parentd073a1c22bee204c3fb7b3ba12dbbd7db919a896 (diff)
downloadazalea-drasl-2a2e82efeb4e090abf9144b39be834972c7a0a4d.tar.xz
make some code more idiomatic
Diffstat (limited to 'azalea-nbt/src/decode.rs')
-rwxr-xr-xazalea-nbt/src/decode.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs
index 314e763e..5164bb0f 100755
--- a/azalea-nbt/src/decode.rs
+++ b/azalea-nbt/src/decode.rs
@@ -18,7 +18,7 @@ fn read_string(stream: &mut impl Read) -> Result<String, Error> {
impl Tag {
#[inline]
fn read_known(stream: &mut impl Read, id: u8) -> Result<Tag, Error> {
- let tag = match id {
+ Ok(match id {
// Signifies the end of a TAG_Compound. It is only ever used inside
// a TAG_Compound, and is not named despite being in a TAG_Compound
0 => Tag::End,
@@ -104,8 +104,7 @@ impl Tag {
Tag::LongArray(longs)
}
_ => return Err(Error::InvalidTagType(id)),
- };
- Ok(tag)
+ })
}
pub fn read(stream: &mut impl Read) -> Result<Tag, Error> {
@@ -137,10 +136,11 @@ impl Tag {
impl McBufReadable for Tag {
fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> {
- match Tag::read(buf) {
- Ok(r) => Ok(r),
- // Err(e) => Err(e.to_string()),
- Err(e) => Err(e.to_string()).unwrap(),
- }
+ Ok(Tag::read(buf)?)
+ }
+}
+impl From<Error> for BufReadError {
+ fn from(e: Error) -> Self {
+ BufReadError::Custom(e.to_string())
}
}