effectful 0.2.0

Effect<A, E, R> (sync + async), context/layers, pipe — interpreter-style, no bundled executor
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Ex 033 — `Layer::succeed` builds a service layer.
use effectful::{Layer, MissingService, Service, run_blocking};

#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Service)]
struct Id {
  value: u64,
}

fn main() {
  let layer = Layer::<Id, MissingService>::succeed(Id { value: 99 });
  let context = run_blocking(layer.build(), ()).expect("build");
  assert_eq!(context.get::<Id>().map(|id| id.value), Some(99));
  println!("033_layer_service ok");
}