Skip to content

Commit

Permalink
Change vec references to slices
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgecrw committed Oct 2, 2024
1 parent 4d59f78 commit c911279
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 94 deletions.
2 changes: 1 addition & 1 deletion musicxml/src/datatypes/pedal_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use musicxml_macros::{DatatypeDeserialize, DatatypeSerialize};
pub enum PedalType {
/// Indicates the start of a damper pedal.
Start,
/// Indicates a pedal lift without a retake.
/// Indicates a pedal lift without a retake.
Stop,
/// Indicates the start of a sostenuto pedal.
Sostenuto,
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/datatypes/xlink_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ use musicxml_macros::{DatatypeDeserialize, DatatypeSerialize};
/// MusicXML only supports the simple type.
#[derive(Debug, PartialEq, Eq, DatatypeDeserialize, DatatypeSerialize)]
pub enum XlinkType {
/// See the definition in the [XML Linking Language recommendation](https://www.w3.org/TR/xlink11/#dt-simplelink).
/// See the definition in the [XML Linking Language recommendation](https://www.w3.org/TR/xlink11/#dt-simplelink).
Simple,
}
2 changes: 1 addition & 1 deletion musicxml/src/elements/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum ArrowContents {
}

impl ContentDeserializer for ArrowContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
if let Some(_) = elements.iter().find(|&el| el.name == "circular-arrow") {
Ok(ArrowContents::Circular(CircularArrowContents::deserialize(elements)?))
} else {
Expand Down
4 changes: 2 additions & 2 deletions musicxml/src/elements/credit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct CreditTextContents {
}

impl ContentDeserializer for CreditTextContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut subcontents: Option<CreditTextSubcontents> = None;
let mut contents = CreditTextContents::default();
for element in elements {
Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct CreditContents {
}

impl ContentDeserializer for CreditContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut contents = CreditContents {
credit_type: Vec::new(),
link: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/direction_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub enum DirectionTypeContents {
}

impl ContentDeserializer for DirectionTypeContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(if let Some(element) = elements.first() {
match element.name.as_str() {
"rehearsal" => DirectionTypeContents::Rehearsal(
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use musicxml_macros::*;
/// Attributes pertaining to the [Glyph] element.
#[derive(Debug, PartialEq, Eq, AttributeDeserialize, AttributeSerialize)]
pub struct GlyphAttributes {
/// The type of glyph that is being defined.
/// The type of glyph that is being defined.
pub r#type: GlyphType,
}

Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/grace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct GraceAttributes {
/// Indicates to make time, not steal time, for grace note playback.
/// The units are in real-time divisions for the grace note.
pub make_time: Option<Divisions>,
/// The value is yes for slashed grace notes and no if no slash is present.
/// The value is yes for slashed grace notes and no if no slash is present.
pub slash: Option<YesNo>,
/// Indicates the percentage of time to steal from the following note for the grace note playback, as for appoggiaturas.
pub steal_time_following: Option<Percent>,
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/harmony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub struct HarmonyContents {
}

impl ContentDeserializer for HarmonyContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut harmony: Vec<HarmonySubcontents> = Vec::new();
for element in elements {
if element.name == "root" || element.name == "numeral" || element.name == "function" {
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/interchangeable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct InterchangeableContents {
}

impl ContentDeserializer for InterchangeableContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut temp_beats: Option<Beats> = None;
let mut time_relation = None;
let mut beat_data = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub enum KeyContents {
}

impl ContentDeserializer for KeyContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(if let Some(_) = elements.iter().find(|&el| el.name == "fifths") {
KeyContents::Explicit(ExplicitKeyContents::deserialize(elements)?)
} else {
Expand Down
4 changes: 2 additions & 2 deletions musicxml/src/elements/lyric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub struct TextLyric {
}

impl ContentDeserializer for TextLyric {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut text_lyric = TextLyric::default();
for el in elements {
match el.name.as_str() {
Expand Down Expand Up @@ -223,7 +223,7 @@ pub enum LyricContents {
}

impl ContentDeserializer for LyricContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(if let Some(_) = elements.iter().find(|&el| el.name == "text") {
LyricContents::Text(TextLyric::deserialize(elements)?)
} else if let Some(_) = elements.iter().find(|&el| el.name == "laughing") {
Expand Down
6 changes: 3 additions & 3 deletions musicxml/src/elements/metronome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub struct BeatBased {
}

impl ContentDeserializer for BeatBased {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut beat_unit: Option<BeatUnit> = None;
let mut beat_unit_dot: Vec<BeatUnitDot> = Vec::new();
let mut beat_unit_tied: Vec<BeatUnitTied> = Vec::new();
Expand Down Expand Up @@ -203,7 +203,7 @@ pub struct MetronomeBased {
}

impl ContentDeserializer for MetronomeBased {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut content = MetronomeBased::default();
for element in elements {
match element.name.as_str() {
Expand Down Expand Up @@ -261,7 +261,7 @@ pub enum MetronomeContents {
}

impl ContentDeserializer for MetronomeContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(
if let Some(_) = elements.iter().find(|&el| el.name == "metronome-note") {
MetronomeContents::MetronomeBased(MetronomeBased::deserialize(elements)?)
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/notations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct NotationsContents {
}

impl ContentDeserializer for NotationsContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut notations = NotationsContents::default();
for child in elements {
match child.name.as_str() {
Expand Down
12 changes: 6 additions & 6 deletions musicxml/src/elements/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub struct GraceNormalInfo {
}

impl ContentDeserializer for GraceNormalInfo {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut chord: Option<Chord> = None;
let mut audible: Option<AudibleType> = None;
let mut tie: Vec<Tie> = Vec::new();
Expand Down Expand Up @@ -157,7 +157,7 @@ pub struct GraceCueInfo {
}

impl ContentDeserializer for GraceCueInfo {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut cue: Option<Cue> = None;
let mut chord: Option<Chord> = None;
let mut audible: Option<AudibleType> = None;
Expand Down Expand Up @@ -222,7 +222,7 @@ pub struct GraceInfo {
}

impl ContentDeserializer for GraceInfo {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(GraceInfo {
grace: Grace::deserialize(elements.first().unwrap())?,
info: if elements.iter().find(|&el| el.name == "cue").is_some() {
Expand Down Expand Up @@ -260,7 +260,7 @@ pub struct CueInfo {
}

impl ContentDeserializer for CueInfo {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut cue: Option<Cue> = None;
let mut chord: Option<Chord> = None;
let mut audible: Option<AudibleType> = None;
Expand Down Expand Up @@ -328,7 +328,7 @@ pub struct NormalInfo {
}

impl ContentDeserializer for NormalInfo {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut chord: Option<Chord> = None;
let mut audible: Option<AudibleType> = None;
let mut duration: Option<Duration> = None;
Expand Down Expand Up @@ -433,7 +433,7 @@ pub struct NoteContents {
}

impl ContentDeserializer for NoteContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut note_contents = NoteContents {
info: if elements.first().unwrap().name == "grace" {
NoteType::Grace(GraceInfo::deserialize(elements)?)
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/ornaments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct OrnamentContents {
}

impl ContentDeserializer for OrnamentContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
Ok(OrnamentContents {
ornaments: elements
.iter()
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/part_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct PartListContents {
}

impl ContentDeserializer for PartListContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut content = PartListContents { content: Vec::new() };
for element in elements {
if element.name == "part-group" {
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct TimeContents {
}

impl ContentDeserializer for TimeContents {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String> {
fn deserialize(elements: &[XmlElement]) -> Result<Self, String> {
let mut beats = Vec::new();
let mut time_beats = None;
let mut interchangeable = None;
Expand Down
2 changes: 1 addition & 1 deletion musicxml/src/elements/wavy_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use musicxml_macros::*;
pub struct WavyLineAttributes {
/// Indicates if this is the start, stop, or continuation of the wavy line. The value should be continue whenever used within a [Barline][super::Barline] element.
pub r#type: StartStopContinue,
/// If yes, the trill accelerates during playback. It is no if not specified.
/// If yes, the trill accelerates during playback. It is no if not specified.
pub acclerate: Option<YesNo>,
/// The number of distinct notes during playback, counting the starting note but not the two-note turn. It is 4 if not specified.
pub beats: Option<TrillBeats>,
Expand Down
4 changes: 2 additions & 2 deletions musicxml_internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pub trait DatatypeDeserializer: Sized {
}

pub trait AttributeDeserializer: Sized {
fn deserialize(attributes: &Vec<(String, String)>) -> Result<Self, String>;
fn deserialize(attributes: &[(String, String)]) -> Result<Self, String>;
}

pub trait ContentDeserializer: Sized {
fn deserialize(elements: &Vec<XmlElement>) -> Result<Self, String>;
fn deserialize(elements: &[XmlElement]) -> Result<Self, String>;
}

pub trait ElementDeserializer: Sized {
Expand Down
Loading

0 comments on commit c911279

Please sign in to comment.