Skip to content

Commit

Permalink
nostr: impl IntoIterator for Tag
Browse files Browse the repository at this point in the history
Closes #678

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Dec 15, 2024
1 parent c60d2e3 commit c616b2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
12 changes: 11 additions & 1 deletion crates/nostr/src/event/tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -346,6 +346,16 @@ impl Tag {
}
}

impl IntoIterator for Tag {
type Item = String;
type IntoIter = IntoIter<Self::Item>;

#[inline]
fn into_iter(self) -> Self::IntoIter {
self.buf.into_iter()
}
}

impl Serialize for Tag {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down

0 comments on commit c616b2f

Please sign in to comment.