each_cons.rs

GitHub Workflow Status Crates.io License docs.rs

A port of ruby's Enumerable#each_cons.

Add it to your dependencies:

toml [dependencies] each_cons = "0.2.0"

And use it:

```rust use each_cons::ConsIterator;

let v = vec!["foo", "bar", "baz"]; for cons in v.iter().eachcons(2) { println!("{}", cons.iter().fold( "".tostring(), |acc, curr| format!("{} {}", acc, curr)) ); } // foo bar // bar baz ```