From bdf1547afbb1d0c82cd52504a949fc5ee1f4f23e Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 10 Jan 2023 20:20:07 +0100 Subject: [PATCH] mp4: Implement IntoIterator for Ilst This is needed for merging tags. --- src/mp4/ilst/mod.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/mp4/ilst/mod.rs b/src/mp4/ilst/mod.rs index 621ff2f9..f2c04737 100644 --- a/src/mp4/ilst/mod.rs +++ b/src/mp4/ilst/mod.rs @@ -83,11 +83,6 @@ pub struct Ilst { } impl Ilst { - /// Returns all of the tag's atoms - pub fn atoms(&self) -> &[Atom<'static>] { - &self.atoms - } - /// Get an item by its [`AtomIdent`] pub fn atom(&self, ident: &AtomIdent<'_>) -> Option<&Atom<'static>> { self.atoms.iter().find(|a| &a.ident == ident) @@ -213,6 +208,24 @@ impl Ilst { } } +impl<'a> IntoIterator for &'a Ilst { + type Item = &'a Atom<'static>; + type IntoIter = std::slice::Iter<'a, Atom<'static>>; + + fn into_iter(self) -> Self::IntoIter { + self.atoms.iter() + } +} + +impl IntoIterator for Ilst { + type Item = Atom<'static>; + type IntoIter = std::vec::IntoIter>; + + fn into_iter(self) -> Self::IntoIter { + self.atoms.into_iter() + } +} + impl Accessor for Ilst { impl_accessor!( artist => ARTIST;