chain-trans

Crates.iochain-trans
lib.rschain-trans
version1.0.0
sourcesrc
created_at2022-08-07 12:34:56.557288
updated_at2022-08-07 12:34:56.557288
descriptionUtility for chaining function applications onto structs in continuation-style
homepagehttps://gitlab.com/infomorphic-matti/chain-trans/
repositoryhttps://gitlab.com/infomorphic-matti/chain-trans/
max_upload_size
id640199
size7,778
Matti (infomorphic-matti)

documentation

https://docs.rs/chain-trans

README

chain-trans

Simple rust utility library for applying functions to structures in chains, and chaining functions together (also, trans rights! 🏳️‍⚧️)).

This lets you write code in fluent style with essentially arbitrary functions - with benefits to readability (in particular, avoiding messy intermediary variables when you use free functions), ease of logging, and structuring code in terms of data transformations.

This crate is inspired by the pleasantness of chaining calls within the framework of rust iterators, maps, and filters.

Examples

use chain_trans::prelude::*;

pub struct Point(f32, f32);

let parameterised_point = 3.0f32
    .trans(|a| Point(a, a * 2))
    .trans_inspect(|Point(x, y)| eprintln!("Current point is at {x}, {y}"));
Commit count: 4

cargo fmt