Crates.io | chaining |
lib.rs | chaining |
version | 0.1.0 |
source | src |
created_at | 2023-01-08 20:26:17.912807 |
updated_at | 2023-01-08 20:26:17.912807 |
description | Adds chaining methods `tap` and `pipe` to every type |
homepage | |
repository | https://github.com/plippe/chaining |
max_upload_size | |
id | 753928 |
size | 4,088 |
Adds chaining methods tap
and pipe
to every type. Inspired by Scala's ChainingOps.
Add chaining
to your dependencies in your Cargo.toml file:
[dependencies]
...
chaining = "x.y.z"
...
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);