docs.rs failed to build morphism-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
morphism-0.4.1
morphism.rs
A structure for suspended closure composition in Rust
Synopsis
The motivation for Morphism
is to provide a means of composing and evaluating an unbounded (within heap constraints) number of closures without blowing the stack. In other words, Morphism
is one way to work around the lack of tail-call optimization in Rust.
Because Morphism
implements the Fn
trait, it is callable like a normal closure and can even be passed around as if it were a closure. See the second example below for an instance of using Morphism
with iterators.
Examples
- Compose
Morphism
with closures or anotherMorphism
:
let mut f = ;
for _ in range
let mut g = ;
for _ in range
// type becomes Morphism<uint, (Option<uint>, bool, String)> so rebind g
let g = g
.tail
.tail
.tail
.head;
let h = f.then;
assert_eq!;
assert_eq!;
- Use
Morphism
in place of a closure when aFn
-like is expected:
use AdditiveIterator;
let mut f = ;
for _ in range
// ::map treats f like any other Fn
let res = range.map.sum;
assert_eq!;
Documentation
See the API documentation here.
Requirements
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.