Function to transform the process data the pipe outputs.
A pipe that processes data using the function.
Pass plain data between pipes.
import std.conv; string result; auto myPipe = pipe(() => 1); myPipe .then(number => number + 2) .then(number => number.to!string) .then(text => text ~ ".0") .then(text => result = text); myPipe(); assert(result == "3.0");
then will resolve pipes it returns.
auto pipe1 = pipe({ }); auto pipe2 = pipe((int number) => 1 + number); int result; pipe1 .then(() => pipe2) .then(value => result = value); pipe1(); assert(result == 0); pipe2(10); assert(result == 11);
Pipes can accept multiple arguments.
int a, b, c; auto pipe = pipe((int newA, int newB, int newC) { a = newA; b = newB; c = newC; }); pipe(1, 2, 3); assert(a == 1); assert(b == 2); assert(c == 3);
Set up a pipe from a delegate.