Crates.io | tuppipe |
lib.rs | tuppipe |
version | |
source | src |
created_at | 2024-04-28 00:05:42.7277 |
updated_at | 2024-10-19 13:55:54.146083 |
description | A simple pipe operator-like implementation using tuples in Rust. |
homepage | https://github.com/david-d-h/tuppipe |
repository | https://github.com/david-d-h/tuppipe |
max_upload_size | |
id | 1222923 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This crate provides a handy Pipe
trait that you can implement for arbitrary types
to use them as pipes in a pipeline.
In the example below the pipe
function generates a PartialPipeline
which can be used to "complete" (invoke) any type that implements Pipe
using the
shift right (>>
) operator.
use tuppipe::pipe;
const fn add_one(to: i32) -> i32 {
to + 1
}
assert_eq!(2, pipe(0) >> (add_one, add_one));
The first element in the tuple (the tuple being the pipeline) after >>
, will receive the 0i32
that you see in the pipe
invocation. The second element in the pipeline will receive the output
from the first element in the pipeline, and so on.
Pipe
Note that Pipe
is currently implemented for both, anything that implements FnOnce
from the standard library and for any tuple with up to 16 elements where each element in the tuple
itself implements Pipe
itself as well.
This means that if you really want a pipeline that's longer than a tuple of 16 elements, you can pretty much infinitely nest tuples in one another.
You can check out the docs for more documentation and examples.