diff --git a/musicxml/examples/read_convert_score1.rs b/musicxml/examples/read_convert_score1.rs index ca21b26..a890a90 100644 --- a/musicxml/examples/read_convert_score1.rs +++ b/musicxml/examples/read_convert_score1.rs @@ -3,5 +3,5 @@ use musicxml::*; fn main() { // Read a MusicXML file of one score type as a different score type let score = read_score_timewise("./musicxml/tests/Grande Valse Brillante.musicxml"); - println! {"{:?}", score}; + println! {"{score:?}"}; } diff --git a/musicxml/examples/read_convert_score2.rs b/musicxml/examples/read_convert_score2.rs index 86a2ca6..ca39195 100644 --- a/musicxml/examples/read_convert_score2.rs +++ b/musicxml/examples/read_convert_score2.rs @@ -3,5 +3,5 @@ use musicxml::*; fn main() { // Read a MusicXML file of one score type as a different score type let score = read_score_partwise("./musicxml/tests/Grande Valse Brillante - Timewise.musicxml"); - println! {"{:?}", score}; + println! {"{score:?}"}; } diff --git a/musicxml/examples/read_musicxml_score.rs b/musicxml/examples/read_musicxml_score.rs index c9a2a64..87a9a42 100644 --- a/musicxml/examples/read_musicxml_score.rs +++ b/musicxml/examples/read_musicxml_score.rs @@ -3,5 +3,5 @@ use musicxml::*; fn main() { // Read and parse a MusicXML file let score = read_score_partwise("./musicxml/tests/Grande Valse Brillante.musicxml"); - println! {"{:?}", score}; + println! {"{score:?}"}; } diff --git a/musicxml/examples/read_mxl_score.rs b/musicxml/examples/read_mxl_score.rs index ef53c75..f15a956 100644 --- a/musicxml/examples/read_mxl_score.rs +++ b/musicxml/examples/read_mxl_score.rs @@ -3,5 +3,5 @@ use musicxml::*; fn main() { // Read and parse a compressed MusicXML file let score = read_score_partwise("./musicxml/tests/Grande Valse Brillante.mxl"); - println! {"{:?}", score}; + println! {"{score:?}"}; } diff --git a/musicxml/src/datatypes/accordion_middle.rs b/musicxml/src/datatypes/accordion_middle.rs index 471426b..6992030 100644 --- a/musicxml/src/datatypes/accordion_middle.rs +++ b/musicxml/src/datatypes/accordion_middle.rs @@ -29,7 +29,7 @@ impl DatatypeDeserializer for AccordionMiddle { 1..=3 => Ok(AccordionMiddle(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/beam_level.rs b/musicxml/src/datatypes/beam_level.rs index dad68aa..e6e3473 100644 --- a/musicxml/src/datatypes/beam_level.rs +++ b/musicxml/src/datatypes/beam_level.rs @@ -26,7 +26,7 @@ impl DatatypeDeserializer for BeamLevel { 1..=8 => Ok(BeamLevel(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/color.rs b/musicxml/src/datatypes/color.rs index e1e2774..2ab6bdc 100644 --- a/musicxml/src/datatypes/color.rs +++ b/musicxml/src/datatypes/color.rs @@ -28,6 +28,7 @@ pub struct Color { impl Color { /// Creates a new [Color] with the given red, green, blue, and alpha values. + #[must_use] pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self { Color { r, g, b, a } } @@ -69,7 +70,7 @@ impl DatatypeDeserializer for Color { )) } } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/comma_separated_text.rs b/musicxml/src/datatypes/comma_separated_text.rs index 141e26e..8cb9755 100644 --- a/musicxml/src/datatypes/comma_separated_text.rs +++ b/musicxml/src/datatypes/comma_separated_text.rs @@ -26,7 +26,7 @@ impl DatatypeDeserializer for CommaSeparatedText { let mut text: Vec = Vec::new(); value.split(',').for_each(|item| { let res = item.trim(); - if res.len() > 0 { + if !res.is_empty() { text.push(res.to_string()); } }); diff --git a/musicxml/src/datatypes/date.rs b/musicxml/src/datatypes/date.rs index d5a7600..6f28757 100644 --- a/musicxml/src/datatypes/date.rs +++ b/musicxml/src/datatypes/date.rs @@ -19,6 +19,7 @@ pub struct Date { impl Date { /// Creates a new [Date] with the given year, month, day, and timezone offset. + #[must_use] pub fn new(year: u16, month: u8, date: u8, timezone_hours: i8, timezone_minutes: u8) -> Self { Date { year, @@ -80,10 +81,10 @@ impl DatatypeDeserializer for Date { { Ok(date) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/decimal.rs b/musicxml/src/datatypes/decimal.rs index b7750cb..8cba8cc 100644 --- a/musicxml/src/datatypes/decimal.rs +++ b/musicxml/src/datatypes/decimal.rs @@ -40,7 +40,7 @@ mod decimal_tests { fn deserialize_valid3() { let result = Decimal::deserialize("3.234234"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), Decimal(3.234234)); + assert_eq!(result.unwrap(), Decimal(3.234_234)); } #[test] diff --git a/musicxml/src/datatypes/divisions.rs b/musicxml/src/datatypes/divisions.rs index 367247d..d4a6f0e 100644 --- a/musicxml/src/datatypes/divisions.rs +++ b/musicxml/src/datatypes/divisions.rs @@ -47,7 +47,7 @@ mod divisions_tests { fn deserialize_valid4() { let result = Divisions::deserialize("223234"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), Divisions(223234)); + assert_eq!(result.unwrap(), Divisions(223_234)); } #[test] diff --git a/musicxml/src/datatypes/ending_number.rs b/musicxml/src/datatypes/ending_number.rs index 2b1879c..7d18d14 100644 --- a/musicxml/src/datatypes/ending_number.rs +++ b/musicxml/src/datatypes/ending_number.rs @@ -30,7 +30,7 @@ impl DatatypeDeserializer for EndingNumber { } else if integer_regex.is_match(value) { Ok(EndingNumber(value.split(' ').collect::>().join(""))) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/fifths.rs b/musicxml/src/datatypes/fifths.rs index c49373c..0d1582e 100644 --- a/musicxml/src/datatypes/fifths.rs +++ b/musicxml/src/datatypes/fifths.rs @@ -24,9 +24,9 @@ impl DatatypeDeserializer for Fifths { match value.parse::() { Ok(val) => match val { -7..=7 => Ok(Fifths(val)), - _ => Err(format!("Value {} is invalid for the data type", value)), + _ => Err(format!("Value {value} is invalid for the data type")), }, - _ => Err(format!("Value {} is invalid for the data type", value)), + _ => Err(format!("Value {value} is invalid for the data type")), } } } diff --git a/musicxml/src/datatypes/font_family.rs b/musicxml/src/datatypes/font_family.rs index c91b401..84824fc 100644 --- a/musicxml/src/datatypes/font_family.rs +++ b/musicxml/src/datatypes/font_family.rs @@ -33,7 +33,7 @@ impl DatatypeDeserializer for FontFamily { let mut res: Vec = Vec::new(); value.split(',').for_each(|item| { let val = item.trim(); - if val.len() > 0 { + if !val.is_empty() { res.push(val.to_string()); } }); diff --git a/musicxml/src/datatypes/font_size.rs b/musicxml/src/datatypes/font_size.rs index 8eba337..ee65c26 100644 --- a/musicxml/src/datatypes/font_size.rs +++ b/musicxml/src/datatypes/font_size.rs @@ -29,12 +29,12 @@ impl DatatypeDeserializer for FontSize { if dec_val > 0.0 { Ok(FontSize::Decimal(dec_val)) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } else if let Ok(font_size) = CssFontSize::deserialize(value) { Ok(FontSize::Css(font_size)) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } @@ -54,7 +54,7 @@ mod font_size_tests { fn deserialize_valid2() { let result = FontSize::deserialize("3"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), FontSize::Decimal(3.0)) + assert_eq!(result.unwrap(), FontSize::Decimal(3.0)); } #[test] diff --git a/musicxml/src/datatypes/integer.rs b/musicxml/src/datatypes/integer.rs index 0054722..7824791 100644 --- a/musicxml/src/datatypes/integer.rs +++ b/musicxml/src/datatypes/integer.rs @@ -31,7 +31,7 @@ mod integer_tests { fn deserialize_valid2() { let result = Integer::deserialize("-234234"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), Integer(-234234)); + assert_eq!(result.unwrap(), Integer(-234_234)); } #[test] diff --git a/musicxml/src/datatypes/measure_text.rs b/musicxml/src/datatypes/measure_text.rs index c0841e7..6423f60 100644 --- a/musicxml/src/datatypes/measure_text.rs +++ b/musicxml/src/datatypes/measure_text.rs @@ -23,10 +23,10 @@ impl Deref for MeasureText { impl DatatypeDeserializer for MeasureText { fn deserialize(value: &str) -> Result { - if value.len() > 0 { + if !value.is_empty() { Ok(MeasureText(String::from(value))) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/midi_128.rs b/musicxml/src/datatypes/midi_128.rs index 4c9f4ff..b2db428 100644 --- a/musicxml/src/datatypes/midi_128.rs +++ b/musicxml/src/datatypes/midi_128.rs @@ -29,7 +29,7 @@ impl DatatypeDeserializer for Midi128 { 1..=128 => Ok(Midi128(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/midi_16.rs b/musicxml/src/datatypes/midi_16.rs index a3d72d3..313d4a5 100644 --- a/musicxml/src/datatypes/midi_16.rs +++ b/musicxml/src/datatypes/midi_16.rs @@ -27,7 +27,7 @@ impl DatatypeDeserializer for Midi16 { 1..=16 => Ok(Midi16(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/midi_16384.rs b/musicxml/src/datatypes/midi_16384.rs index d882893..291e848 100644 --- a/musicxml/src/datatypes/midi_16384.rs +++ b/musicxml/src/datatypes/midi_16384.rs @@ -29,7 +29,7 @@ impl DatatypeDeserializer for Midi16384 { 1..=16384 => Ok(Midi16384(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/non_negative_decimal.rs b/musicxml/src/datatypes/non_negative_decimal.rs index 5c7053d..2b0cec3 100644 --- a/musicxml/src/datatypes/non_negative_decimal.rs +++ b/musicxml/src/datatypes/non_negative_decimal.rs @@ -27,7 +27,7 @@ impl DatatypeDeserializer for NonNegativeDecimal { x if x >= 0.0 => Ok(NonNegativeDecimal(val)), _ => Err(format!("Value {val} is invalid for the NonNegativeDecimal data type")), }, - Err(_) => Err(format!("Invalid value {} for NonNegativeDecimal", value)), + Err(_) => Err(format!("Invalid value {value} for NonNegativeDecimal")), } } } diff --git a/musicxml/src/datatypes/non_negative_integer.rs b/musicxml/src/datatypes/non_negative_integer.rs index ea54a21..0aba3e6 100644 --- a/musicxml/src/datatypes/non_negative_integer.rs +++ b/musicxml/src/datatypes/non_negative_integer.rs @@ -31,7 +31,7 @@ mod non_negative_integer_tests { fn deserialize_valid2() { let result = NonNegativeInteger::deserialize("234566"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), NonNegativeInteger(234566)); + assert_eq!(result.unwrap(), NonNegativeInteger(234_566)); } #[test] diff --git a/musicxml/src/datatypes/number_level.rs b/musicxml/src/datatypes/number_level.rs index 5a3be66..ab6f048 100644 --- a/musicxml/src/datatypes/number_level.rs +++ b/musicxml/src/datatypes/number_level.rs @@ -55,7 +55,7 @@ impl DatatypeDeserializer for NumberLevel { if err.to_string().to_lowercase().contains("eof") { Ok(NumberLevel(1)) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/number_of_lines.rs b/musicxml/src/datatypes/number_of_lines.rs index 8038f53..7ff186d 100644 --- a/musicxml/src/datatypes/number_of_lines.rs +++ b/musicxml/src/datatypes/number_of_lines.rs @@ -27,7 +27,7 @@ impl DatatypeDeserializer for NumberOfLines { 0..=3 => Ok(NumberOfLines(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/number_or_normal.rs b/musicxml/src/datatypes/number_or_normal.rs index e886213..030211f 100644 --- a/musicxml/src/datatypes/number_or_normal.rs +++ b/musicxml/src/datatypes/number_or_normal.rs @@ -31,8 +31,7 @@ impl DatatypeDeserializer for NumberOrNormal { Ok(NumberOrNormal::Normal) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/numeral_value.rs b/musicxml/src/datatypes/numeral_value.rs index 697085c..9ecaddb 100644 --- a/musicxml/src/datatypes/numeral_value.rs +++ b/musicxml/src/datatypes/numeral_value.rs @@ -27,7 +27,7 @@ impl DatatypeDeserializer for NumeralValue { 1..=7 => Ok(NumeralValue(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/octave.rs b/musicxml/src/datatypes/octave.rs index df8d92a..46c35a1 100644 --- a/musicxml/src/datatypes/octave.rs +++ b/musicxml/src/datatypes/octave.rs @@ -23,7 +23,7 @@ impl DatatypeDeserializer for Octave { 0..=9 => Ok(Octave(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/percent.rs b/musicxml/src/datatypes/percent.rs index 7f21e0b..0492c00 100644 --- a/musicxml/src/datatypes/percent.rs +++ b/musicxml/src/datatypes/percent.rs @@ -26,10 +26,10 @@ impl DatatypeDeserializer for Percent { fn deserialize(value: &str) -> Result { match value.parse::() { Ok(val) => match val { - x if x >= 0.0 && x <= 100.0 => Ok(Percent(val)), + x if (0.0..=100.0).contains(&x) => Ok(Percent(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/positive_divisions.rs b/musicxml/src/datatypes/positive_divisions.rs index 119cc7e..a217cd4 100644 --- a/musicxml/src/datatypes/positive_divisions.rs +++ b/musicxml/src/datatypes/positive_divisions.rs @@ -25,7 +25,7 @@ impl DatatypeDeserializer for PositiveDivisions { 1.. => Ok(PositiveDivisions(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/positive_integer.rs b/musicxml/src/datatypes/positive_integer.rs index d855a91..bd8a36b 100644 --- a/musicxml/src/datatypes/positive_integer.rs +++ b/musicxml/src/datatypes/positive_integer.rs @@ -23,7 +23,7 @@ impl DatatypeDeserializer for PositiveInteger { 1.. => Ok(PositiveInteger(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } @@ -43,7 +43,7 @@ mod positive_integer_tests { fn deserialize_valid2() { let result = PositiveInteger::deserialize("2345534234"); assert!(result.is_ok()); - assert_eq!(result.unwrap(), PositiveInteger(2345534234)); + assert_eq!(result.unwrap(), PositiveInteger(2_345_534_234)); } #[test] diff --git a/musicxml/src/datatypes/positive_integer_or_empty.rs b/musicxml/src/datatypes/positive_integer_or_empty.rs index fedcc9e..c44c01a 100644 --- a/musicxml/src/datatypes/positive_integer_or_empty.rs +++ b/musicxml/src/datatypes/positive_integer_or_empty.rs @@ -32,8 +32,7 @@ impl DatatypeDeserializer for PositiveIntegerOrEmpty { )), }, Err(_) => Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )), } } diff --git a/musicxml/src/datatypes/rotation_degrees.rs b/musicxml/src/datatypes/rotation_degrees.rs index a838074..55a90b8 100644 --- a/musicxml/src/datatypes/rotation_degrees.rs +++ b/musicxml/src/datatypes/rotation_degrees.rs @@ -28,10 +28,10 @@ impl DatatypeDeserializer for RotationDegrees { fn deserialize(value: &str) -> Result { match value.parse::() { Ok(val) => match val { - x if x >= -180.0 && x <= 180.0 => Ok(RotationDegrees(val)), + x if (-180.0..=180.0).contains(&x) => Ok(RotationDegrees(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/smufl_accidental_glyph_name.rs b/musicxml/src/datatypes/smufl_accidental_glyph_name.rs index c9432f3..ec2b39e 100644 --- a/musicxml/src/datatypes/smufl_accidental_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_accidental_glyph_name.rs @@ -31,14 +31,12 @@ impl DatatypeDeserializer for SmuflAccidentalGlyphName { Ok(SmuflAccidentalGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/smufl_coda_glyph_name.rs b/musicxml/src/datatypes/smufl_coda_glyph_name.rs index a65f128..5cd4d9f 100644 --- a/musicxml/src/datatypes/smufl_coda_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_coda_glyph_name.rs @@ -27,14 +27,12 @@ impl DatatypeDeserializer for SmuflCodaGlyphName { Ok(SmuflCodaGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/smufl_lyrics_glyph_name.rs b/musicxml/src/datatypes/smufl_lyrics_glyph_name.rs index 765a2fa..a3f1f3d 100644 --- a/musicxml/src/datatypes/smufl_lyrics_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_lyrics_glyph_name.rs @@ -27,14 +27,12 @@ impl DatatypeDeserializer for SmuflLyricsGlyphName { Ok(SmuflLyricsGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/smufl_pictogram_glyph_name.rs b/musicxml/src/datatypes/smufl_pictogram_glyph_name.rs index 96cfaf9..e9c72bc 100644 --- a/musicxml/src/datatypes/smufl_pictogram_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_pictogram_glyph_name.rs @@ -27,14 +27,12 @@ impl DatatypeDeserializer for SmuflPictogramGlyphName { Ok(SmuflPictogramGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the e data type", - value + "Value {value} is invalid for the e data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/smufl_segno_glyph_name.rs b/musicxml/src/datatypes/smufl_segno_glyph_name.rs index c5bc249..ab14c56 100644 --- a/musicxml/src/datatypes/smufl_segno_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_segno_glyph_name.rs @@ -27,14 +27,12 @@ impl DatatypeDeserializer for SmuflSegnoGlyphName { Ok(SmuflSegnoGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/smufl_wavy_line_glyph_name.rs b/musicxml/src/datatypes/smufl_wavy_line_glyph_name.rs index 54d8715..28198a1 100644 --- a/musicxml/src/datatypes/smufl_wavy_line_glyph_name.rs +++ b/musicxml/src/datatypes/smufl_wavy_line_glyph_name.rs @@ -32,14 +32,12 @@ impl DatatypeDeserializer for SmuflWavyLineGlyphName { Ok(SmuflWavyLineGlyphName((*token).clone())) } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } else { Err(format!( - "Value {} is invalid for the data type", - value + "Value {value} is invalid for the data type" )) } } diff --git a/musicxml/src/datatypes/staff_line.rs b/musicxml/src/datatypes/staff_line.rs index 38cf560..120ca77 100644 --- a/musicxml/src/datatypes/staff_line.rs +++ b/musicxml/src/datatypes/staff_line.rs @@ -26,7 +26,7 @@ impl DatatypeDeserializer for StaffLine { 1..=255 => Ok(StaffLine(*val as u8)), _ => Err(format!("Value {} is invalid for the data type", *val)), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/staff_number.rs b/musicxml/src/datatypes/staff_number.rs index dad9720..b723f33 100644 --- a/musicxml/src/datatypes/staff_number.rs +++ b/musicxml/src/datatypes/staff_number.rs @@ -26,7 +26,7 @@ impl DatatypeDeserializer for StaffNumber { 1..=255 => Ok(StaffNumber(*val as u8)), _ => Err(format!("Value {} is invalid for the data type", *val)), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/string_number.rs b/musicxml/src/datatypes/string_number.rs index f135852..2d7596f 100644 --- a/musicxml/src/datatypes/string_number.rs +++ b/musicxml/src/datatypes/string_number.rs @@ -26,7 +26,7 @@ impl DatatypeDeserializer for StringNumber { 1..=255 => Ok(StringNumber(*val as u8)), _ => Err(format!("Value {} is invalid for the data type", *val)), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/time_only.rs b/musicxml/src/datatypes/time_only.rs index 0189cd3..a9b0cb5 100644 --- a/musicxml/src/datatypes/time_only.rs +++ b/musicxml/src/datatypes/time_only.rs @@ -1,5 +1,5 @@ use super::positive_integer::PositiveInteger; -use alloc::{string::String, string::ToString, vec::Vec}; +use alloc::{string::{String, ToString}, vec::Vec}; use core::ops::Deref; use musicxml_internal::{DatatypeDeserializer, DatatypeSerializer}; @@ -25,7 +25,7 @@ impl DatatypeSerializer for TimeOnly { element .0 .iter() - .map(|val| val.to_string()) + .map(ToString::to_string) .collect::>() .join(",") } @@ -42,11 +42,11 @@ impl DatatypeDeserializer for TimeOnly { _ => errs = true, } } else { - errs = true + errs = true; } }); if errs { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } else { Ok(TimeOnly(res)) } diff --git a/musicxml/src/datatypes/tremolo_marks.rs b/musicxml/src/datatypes/tremolo_marks.rs index d97956f..e29a1a1 100644 --- a/musicxml/src/datatypes/tremolo_marks.rs +++ b/musicxml/src/datatypes/tremolo_marks.rs @@ -27,7 +27,7 @@ impl DatatypeDeserializer for TremoloMarks { 0..=8 => Ok(TremoloMarks(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/trill_beats.rs b/musicxml/src/datatypes/trill_beats.rs index bc7491c..bd547f5 100644 --- a/musicxml/src/datatypes/trill_beats.rs +++ b/musicxml/src/datatypes/trill_beats.rs @@ -29,7 +29,7 @@ impl DatatypeDeserializer for TrillBeats { x if x >= 2.0 => Ok(TrillBeats(val)), _ => Err(format!("Value {val} is invalid for the data type")), }, - Err(_) => Err(format!("Invalid value {} for ", value)), + Err(_) => Err(format!("Invalid value {value} for ")), } } } diff --git a/musicxml/src/datatypes/yes_no_number.rs b/musicxml/src/datatypes/yes_no_number.rs index f7a02da..90fde08 100644 --- a/musicxml/src/datatypes/yes_no_number.rs +++ b/musicxml/src/datatypes/yes_no_number.rs @@ -34,7 +34,7 @@ impl DatatypeDeserializer for YesNoNumber { } else if value.to_lowercase() == "no" { Ok(YesNoNumber::No) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/datatypes/yyyy_mm_dd.rs b/musicxml/src/datatypes/yyyy_mm_dd.rs index 2d833f1..089b9dd 100644 --- a/musicxml/src/datatypes/yyyy_mm_dd.rs +++ b/musicxml/src/datatypes/yyyy_mm_dd.rs @@ -17,6 +17,7 @@ pub struct YyyyMmDd { impl YyyyMmDd { /// Creates a new `YyyyMmDd` instance. + #[must_use] pub fn new(year: u16, month: u8, date: u8) -> Self { YyyyMmDd { year, month, date } } @@ -46,10 +47,10 @@ impl DatatypeDeserializer for YyyyMmDd { if date.month > 0 && date.month < 13 && date.date > 0 && date.date < 32 { Ok(date) } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } else { - Err(format!("Value {} is invalid for the data type", value)) + Err(format!("Value {value} is invalid for the data type")) } } } diff --git a/musicxml/src/elements/arrow.rs b/musicxml/src/elements/arrow.rs index b2a4178..e53ea27 100644 --- a/musicxml/src/elements/arrow.rs +++ b/musicxml/src/elements/arrow.rs @@ -74,7 +74,7 @@ pub enum ArrowContents { impl ContentDeserializer for ArrowContents { fn deserialize(elements: &[XmlElement]) -> Result { - if let Some(_) = elements.iter().find(|&el| el.name == "circular-arrow") { + if elements.iter().any(|el| el.name == "circular-arrow") { Ok(ArrowContents::Circular(CircularArrowContents::deserialize(elements)?)) } else { Ok(ArrowContents::Straight(StraightArrowContents::deserialize(elements)?)) diff --git a/musicxml/src/elements/credit.rs b/musicxml/src/elements/credit.rs index 4722d5c..617e37b 100644 --- a/musicxml/src/elements/credit.rs +++ b/musicxml/src/elements/credit.rs @@ -53,14 +53,8 @@ impl ContentDeserializer for CreditTextContents { let mut contents = CreditTextContents::default(); for element in elements { match element.name.as_str() { - "link" => match subcontents.as_mut() { - Some(content) => content.link.push(Link::deserialize(element)?), - _ => (), - }, - "bookmark" => match subcontents.as_mut() { - Some(content) => 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) => { @@ -117,7 +111,7 @@ impl ContentDeserializer for CreditContents { credit_type: Vec::new(), link: Vec::new(), bookmark: Vec::new(), - credit: if let Some(_) = elements.iter().find(|&el| el.name == "credit-image") { + credit: if elements.iter().any(|el| el.name == "credit-image") { CreditSubcontents::Image(CreditImageContents::deserialize(elements)?) } else { CreditSubcontents::Text(CreditTextContents::deserialize(elements)?) @@ -129,12 +123,12 @@ impl ContentDeserializer for CreditContents { "credit-type" => contents.credit_type.push(CreditType::deserialize(element)?), "link" => { if !image_or_words_found { - contents.link.push(Link::deserialize(element)?) + contents.link.push(Link::deserialize(element)?); } } "bookmark" => { if !image_or_words_found { - contents.bookmark.push(Bookmark::deserialize(element)?) + contents.bookmark.push(Bookmark::deserialize(element)?); } } _ => { diff --git a/musicxml/src/elements/direction_type.rs b/musicxml/src/elements/direction_type.rs index 2da7a9b..a58010e 100644 --- a/musicxml/src/elements/direction_type.rs +++ b/musicxml/src/elements/direction_type.rs @@ -175,10 +175,10 @@ impl ContentDeserializer for DirectionTypeContents { } "staff-divide" => DirectionTypeContents::StaffDivide(StaffDivide::deserialize(element)?), "other-direction" => DirectionTypeContents::OtherDirection(OtherDirection::deserialize(element)?), - other => return Err(format!("Unknown child element <{}> of ", other)), + other => return Err(format!("Unknown child element <{other}> of ")), } } else { - Err(format!("Missing required child of element "))? + Err(String::from("Missing required child of element "))? }) } } @@ -237,7 +237,7 @@ impl ContentSerializer for DirectionTypeContents { } } DirectionTypeContents::AccordionRegistration(contents) => { - elements.push(AccordionRegistration::serialize(contents)) + elements.push(AccordionRegistration::serialize(contents)); } DirectionTypeContents::StaffDivide(contents) => elements.push(StaffDivide::serialize(contents)), DirectionTypeContents::OtherDirection(contents) => elements.push(OtherDirection::serialize(contents)), diff --git a/musicxml/src/elements/interchangeable.rs b/musicxml/src/elements/interchangeable.rs index baf5e08..bcf76bc 100644 --- a/musicxml/src/elements/interchangeable.rs +++ b/musicxml/src/elements/interchangeable.rs @@ -50,7 +50,7 @@ impl ContentDeserializer for InterchangeableContents { beats: temp_beat.clone(), beat_type: BeatType::deserialize(element)?, }), - _ => Err(format!("Missing required \"beat\" element prior to \"beat-type\""))?, + _ => Err(String::from("Missing required \"beat\" element prior to \"beat-type\""))?, }; temp_beats = None; } @@ -72,7 +72,7 @@ impl ContentSerializer for InterchangeableContents { } for el in &element.beat_data { elements.push(Beats::serialize(&el.beats)); - elements.push(BeatType::serialize(&el.beat_type)) + elements.push(BeatType::serialize(&el.beat_type)); } elements } diff --git a/musicxml/src/elements/key.rs b/musicxml/src/elements/key.rs index 8d8e05c..cca244f 100644 --- a/musicxml/src/elements/key.rs +++ b/musicxml/src/elements/key.rs @@ -83,7 +83,7 @@ pub enum KeyContents { impl ContentDeserializer for KeyContents { fn deserialize(elements: &[XmlElement]) -> Result { - Ok(if let Some(_) = elements.iter().find(|&el| el.name == "fifths") { + Ok(if elements.iter().any(|el| el.name == "fifths") { KeyContents::Explicit(ExplicitKeyContents::deserialize(elements)?) } else { KeyContents::Relative(RelativeKeyContents::deserialize(elements)?) diff --git a/musicxml/src/elements/lyric.rs b/musicxml/src/elements/lyric.rs index af5b88e..6270bb8 100644 --- a/musicxml/src/elements/lyric.rs +++ b/musicxml/src/elements/lyric.rs @@ -86,28 +86,28 @@ impl ContentDeserializer for TextLyric { match el.name.as_str() { "syllabic" => { if text_lyric.syllabic.is_none() { - text_lyric.syllabic = Some(Syllabic::deserialize(el)?) + text_lyric.syllabic = Some(Syllabic::deserialize(el)?); } else if !text_lyric.additional.is_empty() { - text_lyric.additional.last_mut().unwrap().syllabic = Some(Syllabic::deserialize(el)?) + text_lyric.additional.last_mut().unwrap().syllabic = Some(Syllabic::deserialize(el)?); } } "text" => { if text_lyric.text.content.is_empty() { - text_lyric.text = Text::deserialize(el)? + text_lyric.text = Text::deserialize(el)?; } else if text_lyric.additional.is_empty() { text_lyric.additional.push(AdditionalTextLyric { elision: None, syllabic: None, text: Text::deserialize(el)?, - }) + }); } else if text_lyric.additional.last().unwrap().text.content.is_empty() { - text_lyric.additional.last_mut().unwrap().text = Text::deserialize(el)? + text_lyric.additional.last_mut().unwrap().text = Text::deserialize(el)?; } else { text_lyric.additional.push(AdditionalTextLyric { elision: None, syllabic: None, text: Text::deserialize(el)?, - }) + }); } } "elision" => text_lyric.additional.push(AdditionalTextLyric { @@ -224,11 +224,11 @@ pub enum LyricContents { impl ContentDeserializer for LyricContents { fn deserialize(elements: &[XmlElement]) -> Result { - Ok(if let Some(_) = elements.iter().find(|&el| el.name == "text") { + Ok(if elements.iter().any(|el| el.name == "text") { LyricContents::Text(TextLyric::deserialize(elements)?) - } else if let Some(_) = elements.iter().find(|&el| el.name == "laughing") { + } else if elements.iter().any(|el| el.name == "laughing") { LyricContents::Laughing(LaughingLyric::deserialize(elements)?) - } else if let Some(_) = elements.iter().find(|&el| el.name == "humming") { + } else if elements.iter().any(|el| el.name == "humming") { LyricContents::Humming(HummingLyric::deserialize(elements)?) } else { LyricContents::Extend(ExtendLyric::deserialize(elements)?) diff --git a/musicxml/src/elements/metronome.rs b/musicxml/src/elements/metronome.rs index cfcaad6..6783e4d 100644 --- a/musicxml/src/elements/metronome.rs +++ b/musicxml/src/elements/metronome.rs @@ -107,23 +107,20 @@ impl ContentDeserializer for BeatBased { for element in elements { match element.name.as_str() { "beat-unit" => { - if let Some(_) = beat_unit.as_mut() { + if beat_unit.as_mut().is_some() { equals = Some(BeatEquation::Beats(BeatBasedEquation { beat_unit: BeatUnit::deserialize(element)?, beat_unit_dot: Vec::new(), beat_unit_tied: Vec::new(), - })) + })); } else { beat_unit = Some(BeatUnit::deserialize(element)?); } } "beat-unit-dot" => { if let Some(equation) = equals.as_mut() { - match equation { - BeatEquation::Beats(ref mut beat_equation) => { - beat_equation.beat_unit_dot.push(BeatUnitDot::deserialize(element)?); - } - _ => (), + if let BeatEquation::Beats(ref mut beat_equation) = equation { + beat_equation.beat_unit_dot.push(BeatUnitDot::deserialize(element)?); } } else { beat_unit_dot.push(BeatUnitDot::deserialize(element)?); @@ -131,11 +128,8 @@ impl ContentDeserializer for BeatBased { } "beat-unit-tied" => { if let Some(equation) = equals.as_mut() { - match equation { - BeatEquation::Beats(ref mut beat_equation) => { - beat_equation.beat_unit_tied.push(BeatUnitTied::deserialize(element)?); - } - _ => (), + if let BeatEquation::Beats(ref mut beat_equation) = equation { + beat_equation.beat_unit_tied.push(BeatUnitTied::deserialize(element)?); } } else { beat_unit_tied.push(BeatUnitTied::deserialize(element)?); @@ -144,14 +138,14 @@ impl ContentDeserializer for BeatBased { "per-minute" => { equals = Some(BeatEquation::BPM(PerMinute::deserialize(element)?)); } - other => Err(format!("Unknown subelement <{}> of ", other))?, + other => Err(format!("Unknown subelement <{other}> of "))?, } } Ok(BeatBased { - beat_unit: beat_unit.ok_or_else(|| format!("Missing subelement of "))?, + beat_unit: beat_unit.ok_or_else(|| String::from("Missing subelement of "))?, beat_unit_dot, beat_unit_tied, - equals: equals.ok_or_else(|| format!("Missing some sort of equivalency"))?, + equals: equals.ok_or_else(|| String::from("Missing some sort of equivalency"))?, }) } } @@ -221,9 +215,9 @@ impl ContentDeserializer for MetronomeBased { content.additional = Some(AdditionalMetronomeBasedContents { metronome_relation: MetronomeRelation::deserialize(element)?, metronome_note: vec![], - }) + }); } - other => Err(format!("Unknown subelement <{}> of ", other))?, + other => Err(format!("Unknown subelement <{other}> of "))?, } } Ok(content) @@ -234,10 +228,10 @@ impl ContentSerializer for MetronomeBased { fn serialize(element: &Self) -> Vec { let mut elements: Vec = Vec::new(); if let Some(content) = &element.metronome_arrows { - elements.push(MetronomeArrows::serialize(content)) + elements.push(MetronomeArrows::serialize(content)); } for el in &element.metronome_note { - elements.push(MetronomeNote::serialize(el)) + elements.push(MetronomeNote::serialize(el)); } if let Some(content) = &element.additional { elements.push(MetronomeRelation::serialize(&content.metronome_relation)); @@ -263,7 +257,7 @@ pub enum MetronomeContents { impl ContentDeserializer for MetronomeContents { fn deserialize(elements: &[XmlElement]) -> Result { Ok( - if let Some(_) = elements.iter().find(|&el| el.name == "metronome-note") { + 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/elements/notations.rs b/musicxml/src/elements/notations.rs index c1c137f..e71a10e 100644 --- a/musicxml/src/elements/notations.rs +++ b/musicxml/src/elements/notations.rs @@ -108,7 +108,7 @@ impl ContentDeserializer for NotationsContents { .notations .push(NotationContentTypes::AccidentalMark(AccidentalMark::deserialize( child, - )?)) + )?)); } "other-notation" => notations .notations diff --git a/musicxml/src/elements/note.rs b/musicxml/src/elements/note.rs index 78c2720..a09a209 100644 --- a/musicxml/src/elements/note.rs +++ b/musicxml/src/elements/note.rs @@ -116,7 +116,7 @@ impl ContentDeserializer for GraceNormalInfo { } } Ok(GraceNormalInfo { - chord: if let Some(chord) = chord { Some(chord) } else { None }, + chord: chord, audible: if let Some(audible) = audible { audible } else { @@ -177,7 +177,7 @@ impl ContentDeserializer for GraceCueInfo { } else { Err("Missing element")? }, - chord: if let Some(chord) = chord { Some(chord) } else { None }, + chord: chord, audible: if let Some(audible) = audible { audible } else { @@ -225,7 +225,7 @@ impl ContentDeserializer for GraceInfo { fn deserialize(elements: &[XmlElement]) -> Result { Ok(GraceInfo { grace: Grace::deserialize(elements.first().unwrap())?, - info: if elements.iter().find(|&el| el.name == "cue").is_some() { + info: if elements.iter().any(|el| el.name == "cue") { GraceType::Cue(GraceCueInfo::deserialize(elements)?) } else { GraceType::Normal(GraceNormalInfo::deserialize(elements)?) @@ -282,7 +282,7 @@ impl ContentDeserializer for CueInfo { } else { Err("Missing element")? }, - chord: if let Some(chord) = chord { Some(chord) } else { None }, + chord: chord, audible: if let Some(audible) = audible { audible } else { @@ -345,7 +345,7 @@ impl ContentDeserializer for NormalInfo { } } Ok(NormalInfo { - chord: if let Some(chord) = chord { Some(chord) } else { None }, + chord: chord, audible: if let Some(audible) = audible { audible } else { diff --git a/musicxml/src/elements/percussion.rs b/musicxml/src/elements/percussion.rs index 67d68cd..04e6f22 100644 --- a/musicxml/src/elements/percussion.rs +++ b/musicxml/src/elements/percussion.rs @@ -117,7 +117,7 @@ impl ElementDeserializer for Percussion { "stick" => PercussionContents::Stick(Stick::deserialize(el)?), "stick-location" => PercussionContents::StickLocation(StickLocation::deserialize(el)?), "other-percussion" => PercussionContents::OtherPercussion(OtherPercussion::deserialize(el)?), - other => Err(format!("Unknown sub-element type for : {}", other))?, + other => Err(format!("Unknown sub-element type for : {other}"))?, }, }) } diff --git a/musicxml/src/parser/mod.rs b/musicxml/src/parser/mod.rs index 9c0f4ab..7aa30ab 100644 --- a/musicxml/src/parser/mod.rs +++ b/musicxml/src/parser/mod.rs @@ -44,8 +44,7 @@ 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")) - .and_then(|attr| Some(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 { diff --git a/musicxml/src/parser/xml_parser.rs b/musicxml/src/parser/xml_parser.rs index 899eef1..f516585 100644 --- a/musicxml/src/parser/xml_parser.rs +++ b/musicxml/src/parser/xml_parser.rs @@ -39,23 +39,23 @@ fn read_tag_str(str: &mut core::str::Chars) -> TagType { '\n' => (), '/' => { if in_string { - value.push(c) + value.push(c); } else if i == 0 { - is_closing = true + is_closing = true; } else { - is_self_closing = true + is_self_closing = true; } } '?' | '!' => { if i == 0 { - ignore = true + ignore = true; } } ' ' => { if in_tag { - in_tag = false + in_tag = false; } else if in_string { - value.push(c) + value.push(c); } else { tag.attributes.push((attribute.clone(), value.clone())); in_attribute = true; @@ -67,11 +67,11 @@ fn read_tag_str(str: &mut core::str::Chars) -> TagType { '=' => in_attribute = false, _ => { if in_tag { - tag.name.push(c) + tag.name.push(c); } else if in_attribute { - attribute.push(c) + attribute.push(c); } else { - value.push(c) + value.push(c); } } } @@ -89,7 +89,7 @@ pub fn parse_to_string(xml: &XmlElement, depth: i16) -> String { } xml_str += ["<", &xml.name].concat().as_str(); for (key, value) in &xml.attributes { - xml_str += [" ", &key, "=\"", &value, "\""].concat().as_str(); + xml_str += [" ", key, "=\"", value, "\""].concat().as_str(); } if xml.elements.is_empty() && xml.text.is_empty() { xml_str += "/>"; @@ -121,7 +121,7 @@ pub fn parse_from_string(str: &str) -> Result { TagType::Opening(tag) => open_tags.push(tag), TagType::SelfClosing(tag) => match open_tags.last_mut() { Some(last_open_tag) => last_open_tag.elements.push(tag), - None => return Err(format!("Root tag cannot be self-closing")), + None => return Err(String::from("Root tag cannot be self-closing")), }, TagType::Closing(tag) => { let mut element = open_tags.pop().unwrap(); @@ -143,12 +143,12 @@ pub fn parse_from_string(str: &str) -> Result { } else if ch != '\r' && ch != '\n' && ch != '\t' { if let Some(item) = open_tags.last_mut() { if !item.text.is_empty() || ch != ' ' { - item.text.push(ch) + item.text.push(ch); } } } } - Err(format!("Missing one or more matched tags")) + Err(String::from("Missing one or more matched tags")) } #[cfg(test)] diff --git a/musicxml/src/parser/zip_parser.rs b/musicxml/src/parser/zip_parser.rs index a9273a5..039dc8a 100644 --- a/musicxml/src/parser/zip_parser.rs +++ b/musicxml/src/parser/zip_parser.rs @@ -30,7 +30,7 @@ impl LocalFileHeader { } pub fn from_bytes(ptr: &[u8]) -> &Self { - unsafe { (ptr.as_ptr() as *const Self).as_ref().unwrap_unchecked() } + unsafe { ptr.as_ptr().cast::().as_ref().unwrap_unchecked() } } } @@ -64,7 +64,7 @@ impl CentralFileHeader { } pub fn from_bytes(bytes: &[u8]) -> &Self { - unsafe { (bytes.as_ptr() as *const Self).as_ref().unwrap_unchecked() } + unsafe { bytes.as_ptr().cast::().as_ref().unwrap_unchecked() } } } @@ -82,7 +82,7 @@ struct CentralDirEnd { impl CentralDirEnd { pub fn from_bytes(bytes: &[u8]) -> &Self { - unsafe { (bytes.as_ptr() as *const Self).as_ref().unwrap_unchecked() } + unsafe { bytes.as_ptr().cast::().as_ref().unwrap_unchecked() } } } @@ -100,8 +100,8 @@ impl LocalFile { let _ = decoder.read_to_end(&mut decoded_data); Self { file_name, - compressed_size: details.compressed_size as u64, - uncompressed_size: details.uncompressed_size as u64, + compressed_size: u64::from(details.compressed_size), + uncompressed_size: u64::from(details.uncompressed_size), data: decoded_data, } }