pub struct Ending { /* private fields */ }Expand description
Where a measure stands in an alternative ending: music21’s
RepeatBracket, the bracket drawn over the measures played the first
time through, or the second.
music21 keeps the bracket as a spanner over the measures; a measure here says which ending it is in and whether the bracket opens or closes on it.
Implementations§
Source§impl Ending
impl Ending
Sourcepub fn new(numbers: Vec<u32>, starts: bool, stops: bool) -> Self
pub fn new(numbers: Vec<u32>, starts: bool, stops: bool) -> Self
An ending played the times numbered, opening on this measure where
starts and closing on it where stops. Nought as the only number
is an ending that gives none.
Sourcepub fn placed(self, place: BracketPlace) -> Self
pub fn placed(self, place: BracketPlace) -> Self
The same ending, its bracket put at place in the part.
Sourcepub fn place(&self) -> BracketPlace
pub fn place(&self) -> BracketPlace
Where music21 puts the bracket over this ending in its part.
Sourcepub fn numbers_from_text(text: &str) -> Result<Vec<u32>>
pub fn numbers_from_text(text: &str) -> Result<Vec<u32>>
The times an ending is numbered for, read from text as music21’s
RepeatBracket.number reads it: 1-3 a range, 1, 3 a list,
empty the ending that gives none ([0]).
use music21::bar::Ending;
assert_eq!(Ending::numbers_from_text("1-3")?, vec![1, 2, 3]);
assert_eq!(Ending::numbers_from_text("2, 7")?, vec![2, 7]);
assert_eq!(Ending::numbers_from_text("")?, vec![0]);
assert!(Ending::numbers_from_text("x").is_err());Sourcepub fn numbers_label(numbers: &[u32]) -> String
pub fn numbers_label(numbers: &[u32]) -> String
The times an ending is numbered for, written as music21’s
RepeatBracket.number writes them: 1-3 for a run of three or
more, 2, 3 for two in a row or numbers with gaps, empty for none.
use music21::bar::Ending;
assert_eq!(Ending::numbers_label(&[1, 2, 3]), "1-3");
assert_eq!(Ending::numbers_label(&[2, 3]), "2, 3");
assert_eq!(Ending::numbers_label(&[1, 2, 3, 7]), "1, 2, 3, 7");
assert_eq!(Ending::numbers_label(&[0]), "");Sourcepub fn number_text(&self) -> String
pub fn number_text(&self) -> String
The numbers as MusicXML writes them, 1,2; an ending numbered
nought writes nothing.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ending
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Ending
serde only.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>,
impl Eq for Ending
impl StructuralPartialEq for Ending
Auto Trait Implementations§
impl Forget for Ending
impl Freeze for Ending
impl Move for Ending
impl RefUnwindSafe for Ending
impl Send for Ending
impl Sync for Ending
impl Unpin for Ending
impl UnsafeUnpin for Ending
impl UnwindSafe for Ending
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more