From 86194a46808e4e84d2c4e34ec401c7b0cd441871 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 14 May 2024 21:18:38 +0000 Subject: [PATCH] add borrow::NbtCompound::keys --- simdnbt/README.md | 2 +- simdnbt/src/borrow/compound.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simdnbt/README.md b/simdnbt/README.md index aa14ea9..bfaafd7 100644 --- a/simdnbt/README.md +++ b/simdnbt/README.md @@ -12,7 +12,7 @@ cargo add simdnbt ### 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. ```rust,no_run diff --git a/simdnbt/src/borrow/compound.rs b/simdnbt/src/borrow/compound.rs index e3103f3..f99de40 100644 --- a/simdnbt/src/borrow/compound.rs +++ b/simdnbt/src/borrow/compound.rs @@ -229,6 +229,9 @@ impl<'a> NbtCompound<'a> { pub fn is_empty(&self) -> bool { self.values.is_empty() } + pub fn keys(&self) -> impl Iterator { + self.values.iter().map(|(k, _)| *k) + } pub fn to_owned(&self) -> crate::owned::NbtCompound { crate::owned::NbtCompound {