pub fn fold<F, A>(&self, value: A, f: F) -> Stream<'a, A>
  where
    F: 'a + Fn(A, &Sig) -> A,
    A: 'a,
  {
    let folded_stream = Stream::new();
    let folded_stream_ = folded_stream.new_same();
    let mut boxed = Some(value);

    self.observe(move |sig| {
      if let Some(value) = boxed.take() {
        let output = f(value, sig);
        folded_stream_.send(&output);
        boxed = Some(output);
      }
    });

    folded_stream
  }
/// Fold all signals flowing out of a stream into a stream of values.
Fold all signals flowing out of a stream into a stream of values.
Fold all signals flowing out of a stream into a stream of values .
pub fn fold<F, A>(&self, value: A, f: F) -> Stream<'a, A>
  where
    F: 'a + Fn(A, &Sig) -> A,
    A: 'a,
  {
    let folded_stream = Stream::new();
    let folded_stream_ = folded_stream.new_same();
    let mut boxed = Some(value);
    self.observe(move |sig| {
      if let Some(value) = boxed.take() {
        let output = f(value, sig);
        folded_stream_.send(&output);
        boxed = Some(output);
      }
    });
    folded_stream
  }
pub fn fold < F , A > ( & self , value : A , f : F ) -> Stream < ' a , A > where F : ' a + Fn ( A , & Sig ) -> A , A : ' a , { let folded_stream = Stream :: new ( ) ; let folded_stream_ = folded_stream . new_same ( ) ; let mut boxed = Some ( value ) ; self . observe ( move | sig | { if let Some ( value ) = boxed . take ( ) { let output = f ( value , sig ) ; folded_stream_ . send ( & output ) ; boxed = Some ( output ) ; } } ) ; folded_stream }
Fold all signals flowing out of a stream into a stream of values.
Fold all signals flowing out of a stream into a stream of values .
&self
value
A
f
F
&self
value
A
f
F