composing 0.2.0

Tools to compose functions
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 13.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FedericoStra/composing
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FedericoStra

composing

Tools to compose functions

crates.io docs.rs GitHub GitHub Workflow Status Dependencies status MIT license

This library exports two macros, compose_expr and compose_fn, which allow to easily compose expressions and functions respectively.

They both support right-to-left and left-to-right composition.

Examples

use composing::*;

fn plus_one(x: i32) -> i32 { x + 1 }
fn times_two(x: i32) -> i32 { x * 2 }
fn to_string(x: i32) -> String { x.to_string() }

let composition = compose_fn!(to_string, plus_one, times_two);
assert_eq!(composition(17), "35");

let composition = compose_fn!(times_two => plus_one => to_string);
assert_eq!(composition(17), "35");