GitXplorerGitXplorer
R

existent

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
20f3de67b394b03b99a7263478d3bf21d1e59e40

Simplify blanket impls

RRyman committed 10 years ago
Unverified
789b95fde38c9d55521e314f6a21f389a34b5812

Reimplement lazy evaluation

RRyman committed 10 years ago
Unverified
21659dfdd3637ab5c98c6847ba07c2d61fd9048c

Fix depreciations

RRyman committed 10 years ago
Unverified
fbaa5a8eafca30496070c062b53c8b204bfca50c

Remove lazy eval from readme for now

RRyman committed 10 years ago
Unverified
6baa082acb6e75ffd7df0046dcd8d579c064720f

Add travis

RRyman committed 10 years ago
Unverified
6b38b3c0c6e3088687d905a3f412fb783b3f0ff6

Rustup - Features, Show -> Debug

RRyman committed 10 years ago

README

The README file for this repository.

Convenience traits to help clarify/rubify a common pattern in Rust code.

Examples

When

use existent::When;
let x = 100u32;

assert_eq!(None, x.when(x > 200));
assert_eq!(Some(x), x.when(x < 200));

Unless

use existent::Unless;
let xs = vec!["", "Three", "", "Two", "One"];

let filtered = xs.into_iter()
                 .filter_map(|s| s.unless(s.is_empty()))
                 .collect::<Vec<&str>>();

assert_eq!(filtered, vec!["Three", "Two", "One"])

Lazy evaluation

fn expensive_computation(bar: usize) -> usize {
    42 * bar
}

let mut bar = 1;
assert_eq!(Some(42), (|| expensive_computation(bar)).do_unless(false));
assert_eq!(None, (|| expensive_computation(bar)).do_unless(true));

bar = 2;
assert_eq!(Some(84), (|| expensive_computation(bar)).do_when(true));
assert_eq!(None, (|| expensive_computation(bar)).do_when(false));

Cargo usage

[dependencies.existent]

git = "https://github.com/Ryman/existent.git"