fn fold<F, T: 'a>(self, init: T, func: F) -> Fold<Self, NoContext<F>, T>
    where
        F: 'a + FnMut(&T, &Self::Item) -> T,
    {
        Fold { stream: self, init, func: NoContext(func) }
    }
/// 'Reduce' operation on streams.
///
/// This method takes two arguments: an initial value, and a closure with
/// two arguments: an accumulator and an element. The closure returns the
/// value that the accumulator should have for the next iteration; the
/// initial value is the value the accumulator will have on the first call.
///
/// # Examples
///
/// ```
/// # use reactive_rs::*;
/// let stream = SimpleBroadcast::<i32>::new();
/// let cum_sum = stream.fold(0, |acc, x| acc + x);
/// ```
///
/// # Notes
///
/// - The context is passed down unchanged.
/// - The closure receives all of its arguments by reference.
/// - The return value is a `Stream` object (context type is unchanged;
///   value type is the accumulator type).
'Reduce' operation on streams.
This method takes two arguments: an initial value, and a closure with
two arguments: an accumulator and an element. The closure returns the
value that the accumulator should have for the next iteration; the
initial value is the value the accumulator will have on the first call.
' Reduce ' operation on streams . This method takes two arguments : an initial value and a closure with two arguments : an accumulator and an element . The closure returns the value that the accumulator should have for the next iteration ; the initial value is the value the accumulator will have on the first call .
fn fold<F, T: 'a>(self, init: T, func: F) -> Fold<Self, NoContext<F>, T>
    where
        F: 'a + FnMut(&T, &Self::Item) -> T,
    {
        Fold { stream: self, init, func: NoContext(func) }
    }
fn fold < F , T : ' a > ( self , init : T , func : F ) -> Fold < Self , NoContext < F > , T > where F : ' a + FnMut ( & T , & Self :: Item ) -> T , { Fold { stream : self , init , func : NoContext ( func ) } }
'Reduce' operation on streams.
' Reduce ' operation on streams .
self
init
T
func
F
self
init
T
func
F
examples
None
use reactive_rs::*;
let stream = SimpleBroadcast::::new();
let cum_sum = stream.fold(0, |acc, x| acc + x);
```
let stream = SimpleBroadcast :::: new () ; let cum_sum = stream . fold ( 0 |acc x| acc + x ) ; ` ` `
notes
The context is passed down unchanged.
The closure receives all of its arguments by reference.
The return value is a `Stream` object (context type is unchanged;
value type is the accumulator type).
The context is passed down unchanged . The closure receives all of its arguments by reference . The return value is a ` Stream ` object ( context type is unchanged ; value type is the accumulator type ) .