diff options
Diffstat (limited to 'audio/src/program.rs')
| -rw-r--r-- | audio/src/program.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/audio/src/program.rs b/audio/src/program.rs index b775e24..cd050e3 100644 --- a/audio/src/program.rs +++ b/audio/src/program.rs @@ -52,22 +52,23 @@ use Instruction as I; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Track { - pub ins: Rc<Vec<Instruction>>, + pub ins: Vec<Instruction>, } impl Track { pub fn parse(src: &str) -> parse::Result<Self> { - let ins = Rc::new(parse::parse(src)?); + let ins = parse::parse(src)?; Ok(Self { ins }) } - pub fn merge(self, other: Self) -> Self { + #[must_use] + pub fn merge(&self, other: &Self) -> Self { let mut res = vec![]; let mut l = 0; let mut r = 0; let mut l_pause = 0; let mut r_pause = 0; - let l_ins = self.ins; - let r_ins = other.ins; + let l_ins = &self.ins; + let r_ins = &other.ins; loop { if l >= l_ins.len() && r >= r_ins.len() { @@ -124,7 +125,7 @@ impl Track { } } - Self { ins: Rc::new(res) } + Self { ins: res } } } impl fmt::Display for Track { @@ -141,7 +142,7 @@ impl fmt::Display for Track { #[derive(Debug, Clone, PartialEq, Eq)] pub struct Program { - track: Track, + track: Rc<Track>, priority: u32, looping: bool, pc: usize, @@ -150,7 +151,7 @@ pub struct Program { channels: Channels, } impl Program { - pub const fn new(track: Track, priority: u32, looping: bool) -> Self { + pub const fn new(track: Rc<Track>, priority: u32, looping: bool) -> Self { Self { track, priority, |