butcher 0.1.0

An easy way to interact with structs and enums wrapped in Cows
Documentation

Butcher

Build Status Latest Version Rust Documentation

An easy way to interact with Cowed structs and enums.

Disclaimer

This crate is still in early steps of developpments. It should not be used in production.

Concept

This crate aims to allow allow simple destructuring (for structs), pattern matching (for enums and structs) and iteration (for enums and structs that implement it).

Destructuring

TODO

Pattern matching

See this gist.

Iteration

This crate provide a CowIter type, which allows to write Cow fiendly iterators. See this example:

use std::borrow:Cow;
use butcher::iterator::CowIter;

fn print_numbers(elems: Cow<[u32]>) {
    let mut iter = CowIter::from_cow(elems)

    for element in iter {
        // The type of element is Cow<u32>
        println!("{:?}", element);
    }
}

License