Enum musical_note::Accidental
source · pub enum Accidental {
White,
Sharp,
DoubleSharp,
Flat,
DoubleFlat,
}Variants§
Implementations§
source§impl Accidental
impl Accidental
pub fn to_string_by_note(&self, note: NoteName) -> String
sourcepub fn from_str(name: &str) -> Option<Self>
pub fn from_str(name: &str) -> Option<Self>
“es” is Flat, “is” is Sharp, “white” is White.
Examples found in repository?
src/lib.rs (line 438)
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
fn note_from_str(name: &str) -> Option<(NoteName, Accidental)> {
let note = &name[0..1];
match NoteName::from_str(note) {
Some(note) => {
if name.len() <= 1 {
return Some((note, Accidental::White));
} else {
match Accidental::from_str(&name[1..]) {
Some(acc) => Some((note, acc)),
None => None,
}
}
}
None => None,
}
}Trait Implementations§
source§impl Clone for Accidental
impl Clone for Accidental
source§fn clone(&self) -> Accidental
fn clone(&self) -> Accidental
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Accidental
impl Debug for Accidental
source§impl Default for Accidental
impl Default for Accidental
source§impl<'de> Deserialize<'de> for Accidental
impl<'de> Deserialize<'de> for Accidental
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for Accidental
impl Hash for Accidental
source§impl PartialEq<Accidental> for Accidental
impl PartialEq<Accidental> for Accidental
source§fn eq(&self, other: &Accidental) -> bool
fn eq(&self, other: &Accidental) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd<Accidental> for Accidental
impl PartialOrd<Accidental> for Accidental
source§fn partial_cmp(&self, other: &Accidental) -> Option<Ordering>
fn partial_cmp(&self, other: &Accidental) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more