Add Clone bounds to impl Iterator results

This commit is contained in:
Uwe Klotz 2023-01-12 11:43:06 +01:00 committed by Alex
parent 3df98aff12
commit 76cddb7719
6 changed files with 14 additions and 14 deletions

View file

@ -254,7 +254,7 @@ impl ID3v2Tag {
}
/// Returns all `USLT` frames
pub fn unsync_text(&self) -> impl Iterator<Item = &LanguageFrame> {
pub fn unsync_text(&self) -> impl Iterator<Item = &LanguageFrame> + Clone {
self.frames.iter().filter_map(|f| match f {
Frame {
id: FrameID::Valid(id),
@ -266,7 +266,7 @@ impl ID3v2Tag {
}
/// Returns all `COMM` frames
pub fn comments(&self) -> impl Iterator<Item = &LanguageFrame> {
pub fn comments(&self) -> impl Iterator<Item = &LanguageFrame> + Clone {
self.frames.iter().filter_map(|f| match f {
Frame {
id: FrameID::Valid(id),
@ -691,7 +691,7 @@ impl<'a> Id3v2TagRef<'a, std::iter::Empty<FrameRef<'a>>> {
}
// Create an iterator of FrameRef from a Tag's items for Id3v2TagRef::new
pub(crate) fn tag_frames(tag: &Tag) -> impl Iterator<Item = FrameRef<'_>> + Clone + '_ {
pub(crate) fn tag_frames(tag: &Tag) -> impl Iterator<Item = FrameRef<'_>> + Clone {
let items = tag
.items()
.iter()

View file

@ -259,7 +259,7 @@ where
}
}
pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator<Item = (&str, &str)> {
pub(crate) fn tagitems_into_riff(items: &[TagItem]) -> impl Iterator<Item = (&str, &str)> + Clone {
items.iter().filter_map(|i| {
let item_key = i.key().map_key(TagType::RIFFInfo, true);

View file

@ -118,7 +118,7 @@ impl Ilst {
}
/// Returns all pictures
pub fn pictures(&self) -> impl Iterator<Item = &Picture> {
pub fn pictures(&self) -> impl Iterator<Item = &Picture> + Clone {
const COVR: AtomIdent<'_> = AtomIdent::Fourcc(*b"covr");
self.atoms.iter().filter_map(|a| match a.ident {

View file

@ -61,9 +61,9 @@ impl VorbisComments {
self.vendor = vendor
}
/// Returns the tag's items in (key, value) pairs
pub fn items(&self) -> &[(String, String)] {
&self.items
/// Returns an [`Iterator`] over the stored key/value pairs
pub fn items(&self) -> impl Iterator<Item = (&str, &str)> + Clone {
self.items.iter().map(|(k, v)| (k.as_str(), v.as_str()))
}
/// Gets an item by key
@ -95,7 +95,7 @@ impl VorbisComments {
/// let all_artists = vorbis_comments.get_all("ARTIST").collect::<Vec<&str>>();
/// assert_eq!(all_artists, vec!["Foo artist", "Bar artist", "Baz artist"]);
/// ```
pub fn get_all<'a>(&'a self, key: &'a str) -> impl Iterator<Item = &'a str> + '_ {
pub fn get_all<'a>(&'a self, key: &'a str) -> impl Iterator<Item = &'a str> + Clone + '_ {
self.items
.iter()
.filter_map(move |(k, v)| (k == key).then_some(v.as_str()))

View file

@ -15,7 +15,7 @@ use lofty_attr::LoftyFile;
#[derive(LoftyFile)]
#[lofty(read_fn = "Self::read_from")]
pub struct VorbisFile {
/// The vorbis comments contained in the file
/// The Vorbis Comments contained in the file
///
/// NOTE: While a metadata packet is required, it isn't required to actually have any data.
#[lofty(tag_type = "VorbisComments")]

View file

@ -381,12 +381,12 @@ impl Tag {
}
/// Returns references to all [`TagItem`]s with the specified key
pub fn get_items<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a TagItem> {
pub fn get_items<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a TagItem> + Clone {
self.items.iter().filter(move |i| i.key() == key)
}
/// Returns references to all texts of [`TagItem`]s with the specified key, and [`ItemValue::Text`]
pub fn get_strings<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a str> {
pub fn get_strings<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a str> + Clone {
self.items.iter().filter_map(move |i| {
if i.key() == key {
i.value().text()
@ -397,7 +397,7 @@ impl Tag {
}
/// Returns references to all locators of [`TagItem`]s with the specified key, and [`ItemValue::Locator`]
pub fn get_locators<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a str> {
pub fn get_locators<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a str> + Clone {
self.items.iter().filter_map(move |i| {
if i.key() == key {
i.value().locator()
@ -408,7 +408,7 @@ impl Tag {
}
/// Returns references to all bytes of [`TagItem`]s with the specified key, and [`ItemValue::Binary`]
pub fn get_bytes<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a [u8]> {
pub fn get_bytes<'a>(&'a self, key: &'a ItemKey) -> impl Iterator<Item = &'a [u8]> + Clone {
self.items.iter().filter_map(move |i| {
if i.key() == key {
i.value().binary()