Skip to content

FedericoStra/composing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");

About

Tools to compose functions

Resources

Stars

Watchers

Forks

Packages

No packages published