CrabCraftDev / CrabNBT

Up-to-date Rust crate for easy and intuitive working with NBT data.
https://crates.io/crates/crab_nbt
GNU General Public License v3.0
3 stars 2 forks source link

Implement Hash, PartialOrd, Eq, Ord for types #22

Closed PonasKovas closed 1 month ago

PonasKovas commented 1 month ago

Hello, it would be awesome if the Nbt types could implement these traits, if possible.

And also, quick unrelated question - can the nbt writing methods ever fail with any error other than IO? maybe they should return Result<..., io::Error> instead of crab_nbt::Error?

goteusz-maszyk commented 1 month ago

Well, hashmaps niether do support hashing nor ordering. We cannot also implement Eq because of floats.

SzczurekYT commented 1 month ago

Poor research, not all of them, but some of the traits can be actually implemented.

SzczurekYT commented 1 month ago

Alright I thought more of the traits are actually missing then they are. Sorry for calling you out @goteusz-maszyk Your research was generally correct, but a bit inaccurately described in the comment. This led @Norbiros to make this comment on #18

Maybe switch to Vec<String, NbtTag> instead of Hashmap to preserver order, and resolve https://github.com/CrabCraftDev/CrabNBT/issues/22

which made me a little upset.

The actual situation is as follows:

SzczurekYT commented 1 month ago

TLDR: PartialOrd has been implemented and other traits can't be implemented because of floats