Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
This commit is contained in:
Serial 2021-07-08 19:35:47 -04:00
parent cb725e882d
commit 08ec8fca3a
3 changed files with 6 additions and 8 deletions

View file

@ -124,13 +124,10 @@ pub(crate) fn write_to(
file_bytes.splice(single_value.0..single_value.1, text_chunks); file_bytes.splice(single_value.0..single_value.1, text_chunks);
}, },
(title, author, copyright) => { (title, author, copyright) => {
let items: Vec<(usize, usize)> = vec![title, author, copyright] let items = vec![title, author, copyright];
.iter() let remaining: Vec<&(usize, usize)> = items.iter().flatten().collect();
.filter(|i| i.is_some())
.map(|v| v.unwrap())
.collect();
if let (Some(first), Some(last)) = (items.iter().min(), items.iter().max()) { if let (Some(first), Some(last)) = (remaining.iter().min(), remaining.iter().max()) {
file_bytes.drain(last.0..last.1); file_bytes.drain(last.0..last.1);
file_bytes.splice(first.0..first.1, text_chunks); file_bytes.splice(first.0..first.1, text_chunks);
} }

View file

@ -243,7 +243,7 @@ impl AudioTagEdit for Mp4Tag {
impl AudioTagWrite for Mp4Tag { impl AudioTagWrite for Mp4Tag {
fn write_to(&self, file: &mut File) -> Result<()> { fn write_to(&self, file: &mut File) -> Result<()> {
self.inner.write_to(&file)?; self.inner.write_to(file)?;
Ok(()) Ok(())
} }
fn write_to_path(&self, path: &str) -> Result<()> { fn write_to_path(&self, path: &str) -> Result<()> {

View file

@ -118,7 +118,8 @@
clippy::must_use_candidate, clippy::must_use_candidate,
clippy::doc_markdown, clippy::doc_markdown,
clippy::let_underscore_drop, clippy::let_underscore_drop,
clippy::match_wildcard_for_single_variants clippy::match_wildcard_for_single_variants,
clippy::semicolon_if_nothing_returned
)] )]
mod types; mod types;