morphism.rs

A structure for suspended closure composition in Rust

build status

Example

rust let mut fm: Morphism<uint, uint> = Morphism::new(); for _ in range(0u, 100000u) { fm = fm.push(|:x| x + 42u); } let mut gm: Morphism<uint, uint> = Morphism::new(); for _ in range(0u, 100000u) { gm = gm.push(|:x| x - 42u); } let gm = gm .push(|:x| Some(x)) .push(|:x| x.map(|y| y + 42u)) .push(|:x| x.map(|y| y.to_string())); assert_eq!(fm.then(gm).run(0u), Some(String::from_str("42")));

Documentation

See the API documentation here.

Requirements

  1. Rust
  2. Cargo

You can install both with the following:

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

See Installing Rust for further details.

Usage

$ cargo build ## build library and binary $ cargo test ## run tests in ./tests $ cargo bench ## run benchmarks in ./benches

Discussion

There is an IRC channel on freenode (chat.freenode.net) at #epsilonz.