Closed PonasKovas closed 1 month ago
Well, hashmaps niether do support hashing nor ordering. We cannot also implement Eq because of floats.
Poor research, not all of them, but some of the traits can be actually implemented.
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:
Hash
, Eq
, Ord
can't be implemented in any way because nbt can store floats, which do not implement those traits. So putting stuff into a Vec instead of HashMap as @Norbiros suggested is not going to solve this issue in any way, and only going to cause more problems.PartialOrd
can be actually implemented and it is tracked here https://github.com/CrabCraftDev/CrabNBT/pull/23TLDR: PartialOrd
has been implemented and other traits can't be implemented because of floats
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 ofcrab_nbt::Error
?