Skip to content

Commit

Permalink
Merge pull request #66 from andrewcsmith/make-signal-object-safe
Browse files Browse the repository at this point in the history
Add Self: Sized constraint to by_ref
  • Loading branch information
mitchmindtree authored Sep 7, 2017
2 parents 399244f + dac9431 commit 45702f1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! Working with **Signal**s allows for easy, readable creation of rich and complex DSP graphs with
//! a simple and familiar API.
use {BTreeMap, Duplex, Frame, Sample, Rc, VecDeque};
use {BTreeMap, Duplex, Frame, Sample, Rc, VecDeque, Box};
use interpolate::{Converter, Interpolator};
use core;

Expand Down Expand Up @@ -482,7 +482,9 @@ pub trait Signal {
/// assert_eq!(signal.next(), [4]);
/// }
/// ```
fn by_ref(&mut self) -> &mut Self {
fn by_ref(&mut self) -> &mut Self
where Self: Sized
{
self
}
}
Expand Down Expand Up @@ -1042,6 +1044,16 @@ pub fn noise_simplex<S>(phase: Phase<S>) -> NoiseSimplex<S> {

//// Trait Implementations for Signal Types.

impl<F> Signal for Box<Signal<Frame=F>>
where F: Frame
{
type Frame = F;
#[inline]
fn next(&mut self) -> Self::Frame {
use core::ops::DerefMut;
self.deref_mut().next()
}
}

impl<I> Signal for FromIterator<I>
where I: Iterator,
Expand Down

0 comments on commit 45702f1

Please sign in to comment.