Skip to main content

music21/humdrum/
tandem.rs

1//! A `*` instruction of a Humdrum spine the reader has no object for:
2//! music21's `MiscTandem`.
3
4/// An instruction kept in the score where it was written: music21's
5/// `MiscTandem`.
6///
7/// Its priority is the line it was written on, as music21 gives it.
8///
9/// ```
10/// use music21::humdrum::MiscTandem;
11///
12/// let tandem = MiscTandem::new("*staff1", 2);
13/// assert_eq!(tandem.tandem(), "*staff1");
14/// assert_eq!(tandem.priority(), 2);
15/// ```
16#[derive(Clone, Debug, Default, PartialEq, Eq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18#[must_use]
19pub struct MiscTandem {
20    tandem: String,
21    priority: i32,
22}
23
24impl MiscTandem {
25    /// An instruction with the priority music21 sorts it by.
26    pub fn new(tandem: impl Into<String>, priority: i32) -> Self {
27        Self {
28            tandem: tandem.into(),
29            priority,
30        }
31    }
32
33    /// The instruction as written: music21's `tandem`.
34    pub fn tandem(&self) -> &str {
35        &self.tandem
36    }
37
38    /// music21's `priority`, which sorts it among what stands at its offset.
39    pub fn priority(&self) -> i32 {
40        self.priority
41    }
42}