fix(domain): rename from_str to parse on Note and Chord

This commit is contained in:
2026-04-08 01:33:19 +02:00
parent 422afbb3f2
commit 98370df27a
2 changed files with 18 additions and 11 deletions

View File

@@ -60,7 +60,7 @@ impl Note {
}
}
pub fn from_str(s: &str) -> Option<Note> {
pub fn parse(s: &str) -> Option<Note> {
let (note, consumed) = Self::parse_prefix(s)?;
if consumed == s.len() { Some(note) } else { None }
}
@@ -86,7 +86,7 @@ mod tests {
#[test]
fn parse_cb_enharmonic() {
assert_eq!(Note::from_str("Cb"), Some(Note::B));
assert_eq!(Note::parse("Cb"), Some(Note::B));
}
#[test]
@@ -103,9 +103,9 @@ mod tests {
#[test]
fn parse_note() {
assert_eq!(Note::from_str("F#"), Some(Note::FSharpGFlat));
assert_eq!(Note::from_str("Gb"), Some(Note::FSharpGFlat));
assert_eq!(Note::from_str("A"), Some(Note::A));
assert_eq!(Note::from_str("X"), None);
assert_eq!(Note::parse("F#"), Some(Note::FSharpGFlat));
assert_eq!(Note::parse("Gb"), Some(Note::FSharpGFlat));
assert_eq!(Note::parse("A"), Some(Note::A));
assert_eq!(Note::parse("X"), None);
}
}