1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 15:36:03 +00:00

add borrow::NbtCompound::keys

This commit is contained in:
mat 2024-05-14 21:18:38 +00:00
parent 8e1e0af3ae
commit 86194a4680
2 changed files with 4 additions and 1 deletions

View file

@ -12,7 +12,7 @@ cargo add simdnbt
### Deserializing ### Deserializing
For deserializing, you'll likely want either [simdnbt::borrow::Nbt::read](https://docs.rs/simdnbt/latest/simdnbt/borrow/enum.Nbt.html#method.read) or [simdnbt::owned::Nbt::read](https://docs.rs/simdnbt/latest/simdnbt/owned/enum.Nbt.html#method.read). For deserializing, you'll likely want either [simdnbt::borrow::read](https://docs.rs/simdnbt/latest/simdnbt/borrow/fn.read.html) or [simdnbt::owned::read](https://docs.rs/simdnbt/latest/simdnbt/owned/fn.read.html).
The difference is that the "borrow" variant requires you to keep a reference to the original buffer, but is significantly faster. The difference is that the "borrow" variant requires you to keep a reference to the original buffer, but is significantly faster.
```rust,no_run ```rust,no_run

View file

@ -229,6 +229,9 @@ impl<'a> NbtCompound<'a> {
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.values.is_empty() self.values.is_empty()
} }
pub fn keys(&self) -> impl Iterator<Item = &Mutf8Str> {
self.values.iter().map(|(k, _)| *k)
}
pub fn to_owned(&self) -> crate::owned::NbtCompound { pub fn to_owned(&self) -> crate::owned::NbtCompound {
crate::owned::NbtCompound { crate::owned::NbtCompound {