Skip to content

pvinchon/chaining

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chaining

crates.io Released API docs Continuous Integration

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);