From 63f96b2d5f5e89e1cc36442a6496278629bdb351 Mon Sep 17 00:00:00 2001 From: breel Date: Wed, 11 Mar 2026 13:06:07 -0600 Subject: [PATCH] time for strings --- src/seq.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/seq.rs b/src/seq.rs index 6edd3e2..6778b47 100644 --- a/src/seq.rs +++ b/src/seq.rs @@ -43,7 +43,7 @@ pub struct Seq { beats: Vec<(i32, tone::Tone)>, } -pub fn new() -> Seq { +fn new() -> Seq { Seq::new() } @@ -54,7 +54,7 @@ impl Seq { } } - pub fn pop(&mut self) -> Option { + fn pop(&mut self) -> Option { match self.beats.len() { 0 => None, _ => match self.beats[0].0 { @@ -67,7 +67,7 @@ impl Seq { } } - pub fn append(&mut self, s: S) { + fn append(&mut self, s: S) { self.append_one(s.to_string()); } @@ -94,14 +94,21 @@ mod test { let mut seq = new(); seq.append("c"); seq.append("4d"); - assert_eq!(seq.beats.len(), 2); + seq.append("g 2e"); + assert_eq!(seq.beats.len(), 4); assert_eq!(seq.beats[0], (1 as i32, tone::new("c"))); assert_eq!(seq.beats[1], (4 as i32, tone::new("d"))); + assert_eq!(seq.beats[2], (1 as i32, tone::new("g"))); + assert_eq!(seq.beats[3], (2 as i32, tone::new("e"))); assert_eq!(seq.pop(), Some(tone::new("c"))); for _ in 0..4 { assert_eq!(seq.pop(), Some(tone::new("d"))); } + assert_eq!(seq.pop(), Some(tone::new("g"))); + for _ in 0..2 { + assert_eq!(seq.pop(), Some(tone::new("e"))); + } assert_eq!(seq.pop(), None); } }