pipei
pipei provides pipe{i} methods that let you write function calls in a chaining style:
they bind the first argument to the receiver and return a closure for the remaining arguments.
Borrowed variants let you “view” a value as something else (e.g. String as str, Vec<T> as [T]),
and mutable borrowed variants let you update in place.
Enabling arities
Enable the arities you need via features:
[]
= "0.1" # default: features = ["up_to_5"]
# pipei = { version = "0.1", features = ["up_to_10"] }
# pipei = { version = "0.1", features = ["pipe0", "pipe1", "pipe3"] }
Basic chaining with pipe{i} (by value)
use ;
let out = 2
.pipe1
.pipe1
.pipe2;
assert_eq!;
Pipe0
use Pipe0;
let n = "hello".to_string.pipe0;
assert_eq!;
Borrowed piping
use Pipe2Ref;
use Borrow;
let n = "hello world".to_string
.pipe2_with;
assert_eq!;
Mutable piping
use Pipe1Ref;
let mut v = vec!;
v
.pipe1_with_mut
.pipe1_with_mut
.pipe1_with_mut;
assert_eq!;