diff --git a/musicxml/src/datatypes/number_or_normal.rs b/musicxml/src/datatypes/number_or_normal.rs index 030211f..7079182 100644 --- a/musicxml/src/datatypes/number_or_normal.rs +++ b/musicxml/src/datatypes/number_or_normal.rs @@ -30,9 +30,7 @@ impl DatatypeDeserializer for NumberOrNormal { } else if value.to_lowercase() == "normal" { Ok(NumberOrNormal::Normal) } else { - Err(format!( - "Value {value} is invalid for the data type" - )) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/time_only.rs b/musicxml/src/datatypes/time_only.rs index 0779c3f..f7f240b 100644 --- a/musicxml/src/datatypes/time_only.rs +++ b/musicxml/src/datatypes/time_only.rs @@ -1,5 +1,8 @@ use super::positive_integer::PositiveInteger; -use alloc::{string::{String, ToString}, vec::Vec}; +use alloc::{ + string::{String, ToString}, + vec::Vec, +}; use core::ops::Deref; use musicxml_internal::{DatatypeDeserializer, DatatypeSerializer}; @@ -22,12 +25,7 @@ impl Deref for TimeOnly { impl DatatypeSerializer for TimeOnly { fn serialize(element: &Self) -> String { - element - .0 - .iter() - .map(ToString::to_string) - .collect::>() - .join(",") + element.0.iter().map(ToString::to_string).collect::>().join(",") } } diff --git a/musicxml/src/elements/credit.rs b/musicxml/src/elements/credit.rs index 617e37b..f65fad7 100644 --- a/musicxml/src/elements/credit.rs +++ b/musicxml/src/elements/credit.rs @@ -53,8 +53,16 @@ impl ContentDeserializer for CreditTextContents { let mut contents = CreditTextContents::default(); for element in elements { match element.name.as_str() { - "link" => if let Some(content) = subcontents.as_mut() { content.link.push(Link::deserialize(element)?) }, - "bookmark" => if let Some(content) = subcontents.as_mut() { content.bookmark.push(Bookmark::deserialize(element)?) }, + "link" => { + if let Some(content) = subcontents.as_mut() { + content.link.push(Link::deserialize(element)?) + } + } + "bookmark" => { + if let Some(content) = subcontents.as_mut() { + content.bookmark.push(Bookmark::deserialize(element)?) + } + } "credit-words" => { match subcontents { Some(mut content) => { diff --git a/musicxml/src/elements/metronome.rs b/musicxml/src/elements/metronome.rs index 6783e4d..5381660 100644 --- a/musicxml/src/elements/metronome.rs +++ b/musicxml/src/elements/metronome.rs @@ -256,13 +256,11 @@ pub enum MetronomeContents { impl ContentDeserializer for MetronomeContents { fn deserialize(elements: &[XmlElement]) -> Result { - Ok( - if elements.iter().any(|el| el.name == "metronome-note") { - MetronomeContents::MetronomeBased(MetronomeBased::deserialize(elements)?) - } else { - MetronomeContents::BeatBased(BeatBased::deserialize(elements)?) - }, - ) + Ok(if elements.iter().any(|el| el.name == "metronome-note") { + MetronomeContents::MetronomeBased(MetronomeBased::deserialize(elements)?) + } else { + MetronomeContents::BeatBased(BeatBased::deserialize(elements)?) + }) } } diff --git a/musicxml/src/parser/mod.rs b/musicxml/src/parser/mod.rs index 450beb9..8a3d365 100644 --- a/musicxml/src/parser/mod.rs +++ b/musicxml/src/parser/mod.rs @@ -44,7 +44,8 @@ fn get_musicxml_contents_from_file(path: &str) -> Result { .iter() .find(|&el| el.name == "rootfiles") .and_then(|el| el.elements.iter().find(|&el| el.name == "rootfile")) - .and_then(|el| el.attributes.iter().find(|&attr| attr.0 == "full-path")).map(|attr| attr.1.clone()); + .and_then(|el| el.attributes.iter().find(|&attr| attr.0 == "full-path")) + .map(|attr| attr.1.clone()); } } if let Some(full_path) = &xml_path { @@ -52,7 +53,8 @@ fn get_musicxml_contents_from_file(path: &str) -> Result { .get_file(full_path.as_str()) .ok_or("MXL file missing expected contents")?; core::str::from_utf8(file.data.as_slice()) - .map_err(|e| e.to_string())?.clone_into(&mut contents); + .map_err(|e| e.to_string())? + .clone_into(&mut contents); } else { Err(String::from("Cannot find MusicXML file in compressed archive"))?; } diff --git a/musicxml_macros/src/lib.rs b/musicxml_macros/src/lib.rs index e9827b4..0dcfe0a 100644 --- a/musicxml_macros/src/lib.rs +++ b/musicxml_macros/src/lib.rs @@ -554,11 +554,7 @@ fn deserialize_element_named_struct(element_type: &syn::Ident, fields: &syn::Fie _ => { if field_name == "attributes" { deserialized_fields.push(quote! { #field_name: #type_path::deserialize(&element.attributes)? }); - } else if field - .attrs - .iter() - .any(|attr| attr.path().is_ident("flatten")) - { + } else if field.attrs.iter().any(|attr| attr.path().is_ident("flatten")) { deserialized_fields.push(quote! { #field_name: #type_path::deserialize(&element.elements)? }); } else { deserialized_fields.push(quote! { #field_name: #type_path::deserialize(element.text.as_str())? }); @@ -609,11 +605,7 @@ fn serialize_element_named_struct( _ => { if field_name == "attributes" { serialized_fields.push(quote! { attributes: #type_path::serialize(&element.attributes) }); - } else if field - .attrs - .iter() - .any(|attr| attr.path().is_ident("flatten")) - { + } else if field.attrs.iter().any(|attr| attr.path().is_ident("flatten")) { serialized_fields.push(quote! { elements: #type_path::serialize(&element.content) }); } else { serialized_fields.push(quote! { text: #type_path::serialize(&element.content) });