diff --git a/CHANGELOG.md b/CHANGELOG.md index a2eff4ca2..5910b1f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ * nostr: add `Tags::challenge` method ([Yuki Kishimoto]) * nostr: add `RelayUrl::is_local_addr` ([Yuki Kishimoto]) * nostr: add `TagKind::k` constructor ([Yuki Kishimoto]) +* nostr: impl `IntoIterator` for `Tag` ([Yuki Kishimoto]) * database: impl PartialEq and Eq for `Events` ([Yuki Kishimoto]) * database: add `SaveEventStatus` enum ([Yuki Kishimoto]) * pool: add `ReceiverStream` ([Yuki Kishimoto]) diff --git a/crates/nostr/src/event/tag/mod.rs b/crates/nostr/src/event/tag/mod.rs index 63f528640..d3873eeb7 100644 --- a/crates/nostr/src/event/tag/mod.rs +++ b/crates/nostr/src/event/tag/mod.rs @@ -5,7 +5,7 @@ //! Tag use alloc::string::{String, ToString}; -use alloc::vec::Vec; +use alloc::vec::{IntoIter, Vec}; #[cfg(not(feature = "std"))] use core::cell::OnceCell; use core::cmp::Ordering; @@ -346,6 +346,16 @@ impl Tag { } } +impl IntoIterator for Tag { + type Item = String; + type IntoIter = IntoIter; + + #[inline] + fn into_iter(self) -> Self::IntoIter { + self.buf.into_iter() + } +} + impl Serialize for Tag { fn serialize(&self, serializer: S) -> Result where