id_effect 3.0.0

Effect<A, E, R> (sync + async), capability DI, pipe — interpreter-style, no bundled executor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Ex 071 — `map_serial` when a closure captures mutable state (not `Send`).
//!
//! Default `Stream::map` uses Rayon on large chunks; `map_serial` keeps chunk work
//! on the current thread with `FnMut` closures.
use id_effect::{Stream, run_blocking};

fn main() {
  let mut offset = 0_i32;
  let s = Stream::from_iterable(1..=8).map_serial(move |n| {
    offset += 1;
    n + offset
  });
  let v = run_blocking(s.run_collect(), ()).expect("collect");
  assert_eq!(v, vec![2, 4, 6, 8, 10, 12, 14, 16]);
  println!("071_stream_map_serial ok");
}