diff --git a/src/ogg/flac/write.rs b/src/ogg/flac/write.rs index 440dcf21..07a8adf0 100644 --- a/src/ogg/flac/write.rs +++ b/src/ogg/flac/write.rs @@ -125,7 +125,7 @@ fn create_comment_block( writer.write_u32::(count)?; - create_comments(writer, &mut count, items)?; + create_comments(writer, &mut count, &mut peek)?; let len = (writer.get_ref().len() - 1) as u32; diff --git a/src/ogg/tag.rs b/src/ogg/tag.rs index d4a9ea11..6a509f64 100644 --- a/src/ogg/tag.rs +++ b/src/ogg/tag.rs @@ -193,8 +193,10 @@ impl From for VorbisComments { _ => continue, }; - // Safe to unwrap since all ItemKeys map in Vorbis comments - let key = item.key().map_key(TagType::VorbisComments, true).unwrap(); + let key = match item.key().map_key(TagType::VorbisComments, true) { + None => continue, + Some(k) => k, + }; vorbis_comments .items @@ -249,9 +251,10 @@ impl<'a> Into> for &'a Tag { let vendor = self.get_string(&ItemKey::EncoderSoftware).unwrap_or(""); let items = self.items.iter().filter_map(|i| match i.value() { - ItemValue::Text(val) | ItemValue::Locator(val) => { - Some((i.key().map_key(TagType::VorbisComments, true).unwrap(), val)) - }, + ItemValue::Text(val) | ItemValue::Locator(val) => i + .key() + .map_key(TagType::VorbisComments, true) + .map(|key| (key, val)), _ => None, });