diff options
| author | Ubuntu <github@matdoes.dev> | 2022-04-23 04:14:19 +0000 |
|---|---|---|
| committer | Ubuntu <github@matdoes.dev> | 2022-04-23 04:14:19 +0000 |
| commit | 46454793e041dcecb252084b6616bd8f7011b2e1 (patch) | |
| tree | 80f6e567c35958b01ac09a7867ff2558de37aae6 | |
| parent | 3a6810ca1dd86d45e5102a839a916e16e6a52130 (diff) | |
| download | azalea-drasl-46454793e041dcecb252084b6616bd8f7011b2e1.tar.xz | |
clean up some code
| -rwxr-xr-x | azalea-nbt/src/encode.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/azalea-nbt/src/encode.rs b/azalea-nbt/src/encode.rs index 27cfe3af..08d41e89 100755 --- a/azalea-nbt/src/encode.rs +++ b/azalea-nbt/src/encode.rs @@ -112,39 +112,34 @@ fn write_list(writer: &mut dyn Write, value: &Vec<Tag>) -> Result<(), Error> { writer.write_i32::<BE>(value.len() as i32)?; match first_tag { Tag::Int(_) => { - // assert all items are the same variant - // assert_eq!(value.iter().all(|tag| tag.id() == 1), true); - for i in value { - assert!(matches!(i, Tag::Int(_))); + for tag in value { writer.write_i32::<BE>( - *i.as_int().expect("List of Int should only contains Int"), + *tag.as_int().expect("List of Int should only contains Int"), )?; } } Tag::String(_) => { - for i in value { - assert!(matches!(i, Tag::String(_))); + for tag in value { write_string( writer, - i.as_string() + tag.as_string() .expect("List of String should only contain String"), )?; } } Tag::Compound(_) => { - for i in value { - assert!(matches!(i, Tag::Compound(_))); + for tag in value { write_compound( writer, - i.as_compound() + tag.as_compound() .expect("List of Compound should only contain Compound"), true, )?; } } _ => { - for i in value { - i.write_without_end(writer)?; + for tag in value { + tag.write_without_end(writer)?; } } } |
