chaining

Crates.iochaining
lib.rschaining
version0.1.0
sourcesrc
created_at2023-01-08 20:26:17.912807
updated_at2023-01-08 20:26:17.912807
descriptionAdds chaining methods `tap` and `pipe` to every type
homepage
repositoryhttps://github.com/plippe/chaining
max_upload_size
id753928
size4,088
Philippe Hosey-Vinchon (plippe)

documentation

README

Chaining

crates.io Released API docs

Adds chaining methods tap and pipe to every type. Inspired by Scala's ChainingOps.

Getting Started

Add chaining to your dependencies in your Cargo.toml file:

[dependencies]
...
chaining = "x.y.z"
...

Examples

use chaining::*;

let times6 = |i: i8| i * 6;
let i = (1 - 2 - 3).pipe(times6).pipe(i8::abs);
assert_eq!(24, i);

let xs = &[1, 2, 3].tap(|xs| println!("debug {}", xs.len()));
assert_eq!(&[1, 2, 3], xs);
Commit count: 5

cargo fmt