Remove user-provided Cows for Picture::new

Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
This commit is contained in:
Serial 2021-07-10 12:16:22 -04:00
parent 9fe7f6dbef
commit 72e361a097
3 changed files with 6 additions and 10 deletions

View file

@ -228,11 +228,7 @@ impl AudioTagEdit for Mp4Tag {
}
}
if pictures.is_empty() {
None
} else {
Some(Cow::from(pictures))
}
(!(pictures.is_empty())).then(|| Cow::from(pictures))
}
fn set_pictures(&mut self, pictures: Vec<Picture>) {
self.remove_pictures();

View file

@ -87,7 +87,7 @@ pub trait AudioTagEdit {
/// Removes the front cover
fn remove_back_cover(&mut self) {}
/// Returns an `Iterator` over all pictures stored in the track
/// Returns all pictures stored in the track, or `None` if empty
fn pictures(&self) -> Option<Cow<'static, [Picture]>> {
None
}

View file

@ -306,14 +306,14 @@ impl Picture {
pub fn new(
pic_type: PictureType,
mime_type: MimeType,
description: Option<Cow<'static, str>>,
data: Cow<'static, [u8]>,
description: Option<String>,
data: Vec<u8>,
) -> Self {
Self {
pic_type,
mime_type,
description,
data,
description: description.map(Cow::from),
data: Cow::from(data),
}
}