From ad87c16be4d2e75c80f76b37fc21c9ab0734da7c Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Fri, 1 Sep 2017 07:35:23 -0700 Subject: [PATCH] ZipMap takes two args, rename frame Fout to F --- src/signal.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/signal.rs b/src/signal.rs index 5426232d..ba597ddb 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -523,19 +523,19 @@ pub struct GenMut { /// A signal that maps from one signal to another #[derive(Clone)] -pub struct Map { +pub struct Map { map: M, signal: S, - frames: core::marker::PhantomData, + frames: core::marker::PhantomData, } /// A signal that iterates two signals in parallel and combines them with a function #[derive(Clone)] -pub struct ZipMap { +pub struct ZipMap { map: M, this: S, other: O, - frame: core::marker::PhantomData + frame: core::marker::PhantomData } /// A type that wraps an Iterator and provides a `Signal` implementation for it. @@ -856,10 +856,10 @@ pub fn gen_mut(gen_mut: G) -> GenMut /// assert_eq!(mapper.next(), [0.5, 0.25]); /// } /// ``` -pub fn map(signal: S, map: M) -> Map - where M: FnMut(::Frame) -> Fout, +pub fn map(signal: S, map: M) -> Map + where M: FnMut(S::Frame) -> F, S: Signal, - Fout: Frame, + F: Frame, { Map { map: map, @@ -881,17 +881,17 @@ pub fn map(signal: S, map: M) -> Map /// fn main() { /// let frames = signal::gen(|| [0.5]); /// let more_frames = signal::gen(|| [0.25]); -/// let mut mapper = signal::zip_map(frames, more_frames, |(f, o)| [f[0], o[0]]); +/// let mut mapper = signal::zip_map(frames, more_frames, |f, o| [f[0], o[0]]); /// assert_eq!(mapper.next(), [0.5, 0.25]); /// assert_eq!(mapper.next(), [0.5, 0.25]); /// assert_eq!(mapper.next(), [0.5, 0.25]); /// } /// ``` -pub fn zip_map(this: S, other: O, map: M) -> ZipMap - where M: FnMut((::Frame, ::Frame)) -> Fout, +pub fn zip_map(this: S, other: O, map: M) -> ZipMap + where M: FnMut(S::Frame, O::Frame) -> F, S: Signal, O: Signal, - Fout: Frame, + F: Frame, { ZipMap { map: map, @@ -1186,12 +1186,12 @@ impl Signal for GenMut } -impl Signal for Map - where M: FnMut(::Frame) -> Fout, +impl Signal for Map + where M: FnMut(S::Frame) -> F, S: Signal, - Fout: Frame, + F: Frame, { - type Frame = Fout; + type Frame = F; #[inline] fn next(&mut self) -> Self::Frame { (self.map)(self.signal.next()) @@ -1199,16 +1199,16 @@ impl Signal for Map } -impl Signal for ZipMap - where M: FnMut((::Frame, ::Frame)) -> Fout, +impl Signal for ZipMap + where M: FnMut(S::Frame, O::Frame) -> F, S: Signal, O: Signal, - Fout: Frame, + F: Frame, { - type Frame = Fout; + type Frame = F; #[inline] fn next(&mut self) -> Self::Frame { - (self.map)((self.this.next(), self.other.next())) + (self.map)(self.this.next(), self.other.next()) } }