diff --git a/src/ape/tag/mod.rs b/src/ape/tag/mod.rs index 19481f54..17d59573 100644 --- a/src/ape/tag/mod.rs +++ b/src/ape/tag/mod.rs @@ -396,8 +396,10 @@ where } } -pub(crate) fn tagitems_into_ape(items: &[TagItem]) -> impl Iterator> { - items.iter().filter_map(|i| { +pub(crate) fn tagitems_into_ape<'a>( + items: impl IntoIterator, +) -> impl Iterator> { + items.into_iter().filter_map(|i| { i.key().map_key(TagType::APE, true).map(|key| ApeItemRef { read_only: false, key, diff --git a/src/id3/v2/tag.rs b/src/id3/v2/tag.rs index 758fdac4..d402ae6b 100644 --- a/src/id3/v2/tag.rs +++ b/src/id3/v2/tag.rs @@ -694,7 +694,6 @@ impl<'a> Id3v2TagRef<'a, std::iter::Empty>> { pub(crate) fn tag_frames(tag: &Tag) -> impl Iterator> + Clone { let items = tag .items() - .iter() .map(TryInto::>::try_into) .filter_map(Result::ok); @@ -1263,19 +1262,20 @@ mod tests { let tag: Tag = tag.into(); assert_eq!(tag.item_count(), 2); - assert_eq!( - tag.items(), - &[ - TagItem::new( - ItemKey::Unknown(String::from("FOO_TEXT_FRAME")), - ItemValue::Text(String::from("foo content")) - ), - TagItem::new( - ItemKey::Unknown(String::from("BAR_URL_FRAME")), - ItemValue::Locator(String::from("bar url")) - ), - ] - ); + let expected_items = [ + TagItem::new( + ItemKey::Unknown(String::from("FOO_TEXT_FRAME")), + ItemValue::Text(String::from("foo content")), + ), + TagItem::new( + ItemKey::Unknown(String::from("BAR_URL_FRAME")), + ItemValue::Locator(String::from("bar url")), + ), + ]; + assert!(expected_items + .iter() + .zip(tag.items()) + .all(|(expected, actual)| expected == actual)); let tag: ID3v2Tag = tag.into(); diff --git a/src/iff/wav/tag/mod.rs b/src/iff/wav/tag/mod.rs index 25d1f8d7..ac30d887 100644 --- a/src/iff/wav/tag/mod.rs +++ b/src/iff/wav/tag/mod.rs @@ -259,8 +259,10 @@ where } } -pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator + Clone { - items.iter().filter_map(|i| { +pub(crate) fn tagitems_into_riff<'a>( + items: impl IntoIterator, +) -> impl Iterator { + items.into_iter().filter_map(|i| { let item_key = i.key().map_key(TagType::RIFFInfo, true); match (item_key, i.value()) { diff --git a/src/tag/mod.rs b/src/tag/mod.rs index 36df41d7..decb5ca4 100644 --- a/src/tag/mod.rs +++ b/src/tag/mod.rs @@ -247,8 +247,8 @@ impl Tag { } /// Returns the stored [`TagItem`]s as a slice - pub fn items(&self) -> &[TagItem] { - &self.items + pub fn items(&self) -> impl Iterator + Clone { + self.items.iter() } /// Returns a reference to a [`TagItem`] matching an [`ItemKey`]