A tiny crate mimicking Elixir's pipe operator for Rust without macros.

Overview

Pipette

A small crate for using pipes in Rust.

use pipette::{Pipeline, pipe};

let input = 1;

let output = pipe((
    input
    |a| a * 2,
    |a| a * 3,
    |a| a * 4,
    |a| a * 5,
    |a| a * 6,
    |a| a * 7,
    |a| a * 8,
));

assert_eq!(output, 40_320);

Pipette is unique:

  • Supports polymorphic pipeline sizes
  • Integrates well with IDE
  • Does not require macros or custom traits

How to use Pipette

Pipette uses trait-based polymorphism (the Pipeline trait) to make it easy to assemble closure-based pipelines in Rust. A single pipeline may consist of up to 12 closures and does not require static typing (ie pipe3, pipe4, pipe5 etc.). Instead, the Pipeline trait will allow any tuple, calling compute any any size of pipeline.

fn add_one(a: i32) -> i32 {
    a + 1
}

let r0 = pipe((0, add_one, add_one));
let r1 = pipe((0, add_one, add_one, add_one));
let r2 = pipe((0, add_one, add_one, add_one, add_one));
let r3 = pipe((0, add_one, add_one, add_one, add_one, add_one));

// lazy pipeline
let add_three = (0, add_one, add_one, add_one);

add_three.compute();

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Pipette by you, shall be licensed as MIT, without any additional terms or conditions.

You might also like...
Macros for candle-lora.

candle-lora-macro This library makes using candle-lora as simple as adding 2 macros to your model structs and calling a method! It is inspired by the

 RusTiny -- A Rust implementation of Tiny+ language
RusTiny -- A Rust implementation of Tiny+ language

RusTiny -- A Rust implementation of Tiny+ language 编译器实践 基本要求: 参考《编译原理及实践》的TINY语言编译器(已上传到群中)完成TINY+ 语言(见附录 A)的解释器:即给定满足 TINY+语言的源代码输入,你的解 释器可以给出对其的解释执

Click-once - A small tiny little binary to fix undesired mouse double clicks in Windows, written in Rust.

click-once A small tiny little binary to fix malfunctioning mouse double clicks in Windows, written in Rust. Minimal executable with little to no over

Tiny Commands Toolchain

Tiny Commands Toolchain: TCT A 1.62MB (release profile) monolithic commands kit for casual terminal usage without any run-time dependency. MMade in 17

Tiny Discord ticket support bot that utilizes the OpenAI GPT-3.5-turbo model.
Tiny Discord ticket support bot that utilizes the OpenAI GPT-3.5-turbo model.

BDFD AI Mod Our tiny Discord ticket support bot that utilizes the OpenAI GPT-3.5-turbo model. This project aims to help users by providing a very fast

Memory.lol - a tiny web service that provides historical information about social media accounts

memory.lol Overview This project is a tiny web service that provides historical information about social media accounts. It can currently be used to l

📦  Crate Protocol allows anyone to create, manage, and trade a tokenized basket of assets, which we refer to as a Crate.
📦 Crate Protocol allows anyone to create, manage, and trade a tokenized basket of assets, which we refer to as a Crate.

📦 Crate Protocol Crate Protocol allows anyone to create, manage, and trade a tokenized basket of assets, which we refer to as a Crate. A Crate is alw

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle!

dm-jitaux is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle (such as rewriting/refactroing your DM code).

Build fast, reward everyone, and scale without friction.
Build fast, reward everyone, and scale without friction.

Scrypto Language for building DeFi apps on Radix. Terminology Package: A collection of blueprints, compiled and published as a single unit. Blueprint:

Comments
  • why not use generic arrays?

    why not use generic arrays?

    thank you for great idea but I wonder why arrays are not used instead of tuple, does this implementation have an advantage? sample code :

    pub fn pip<T, F, const N: usize>(init: T, funcs: [F; N]) -> T
    where
        F: FnOnce(T) -> T,
    {
        let mut r = init;
        for f in funcs {
            r = f(r)
        }
        r
    }
    
    opened by robatipoor 1
Owner
Jonathan Kelley
Systems engineer. Passionate about complex systems, data, and business.
Jonathan Kelley
Tiny crate that allows to wait for a stop signal across multiple threads

Tiny crate that allows to wait for a stop signal across multiple threads. Helpful mostly in server applications that run indefinitely and need a signal for graceful shutdowns.

Dominik Nakamura 5 Dec 16, 2022
Use enum to predicate something, support | and & operator.

Predicate Use enum to predicate something. Just need to implement Predicate Trait with predicate-macros crate, support | and & operator. Don't impleme

上铺小哥 9 Feb 8, 2022
Single-operator public liveness notification

Single-operator public liveness notification

Charlotte Som 1 Feb 16, 2022
A copypastable guide to implementing simple derive macros in Rust.

A copypastable guide to implementing simple derive macros in Rust. The goal Let's say we have a trait with a getter trait MyTrait {

Imbolc 131 Dec 27, 2022
todo-or-die provides procedural macros that act as checked reminders.

todo-or-die provides procedural macros that act as checked reminders.

David Pedersen 552 Dec 24, 2022
twilight-interactions is a set of macros and utilities to work with Discord Interactions using twilight.

Twilight interactions twilight-interactions is a set of macros and utilities to work with Discord Interactions using twilight. Note: This crate is not

null 24 Dec 26, 2022
Procedural macros for Floccus

floccus-proc Procedural macros for floccus This crate contains procedural attribute macros (currently only one) used by the floccus. But potentially c

ScaleWeather 1 Nov 4, 2021
A metamacro toolkit for writing complex macros.

Big Mac This crate contains the branching_parser! metamacro, which can be used to create complex macros with few lines of code. To use the macro, call

null 1 Nov 14, 2021
Provide expansion of proc-macros, in a way that rustc directs you directly to the issues at hand

expander Expands a proc-macro into a file, and uses a include! directive in place. Advantages Only expands a particular proc-macro, not all of them. I

Bernhard Schuster 16 Oct 5, 2022
Macros to make writing proc-macro crates easy

proc-easy Macros to make writing proc-macro crates easy. This crate provides mainly macros and supporting types and traits to reduce amount of boilerp

Zakarum 7 Jan 1, 2023