Skip to main content

music21/stream/
status.rs

1//! What music21's `stream.streamStatus` decides that is not about Python
2//! objects: whether a stream's tuplet brackets have been made.
3
4/// Whether tuplet brackets have been made, from the notes with tuplets, in
5/// order, each saying whether its first tuplet has a bracket type: `None`
6/// where there are no such notes, `Some(true)` once one has a type, and
7/// `Some(false)` where none does. music21's `haveTupletBracketsBeenMade`.
8///
9/// ```
10/// use music21::stream::status::tuplet_brackets_made;
11///
12/// assert_eq!(tuplet_brackets_made([]), None);
13/// assert_eq!(tuplet_brackets_made([false, false]), Some(false));
14/// assert_eq!(tuplet_brackets_made([false, true]), Some(true));
15/// ```
16pub fn tuplet_brackets_made(first_typed: impl IntoIterator<Item = bool>) -> Option<bool> {
17    let mut found = None;
18    for typed in first_typed {
19        if typed {
20            return Some(true);
21        }
22        found = Some(false);
23    }
24    found
25}