Ribbon - tape for Iterators

Ribbon is meant to provide API for holding (and thus making available) some number of items returned by iterators.

This is meant for cases where using iterators is convenient, but some context around the item returned by an iterator is needed. This is especially useful when look-ahead is necessary (we need to know what values come after the current one before deciding what to do with it).

This crate provides two types that implement the Ribbon trait:

Examples:

Using Tape

```rust use ribbon::Tape;

let mut tape = Tape::new(0..10); tape.expand_n(5);

asserteq!(tape.len(), 5); asserteq!(tape.peekfront(), Some(&0)); asserteq!(tape.peek_back(), Some(&4)); ```

Using Band

```rust use ribbon::Band;

// Band with capacity for 5 items let mut band: Band<3, _, _> = Band::new(0..4); band.expand_n(2); // consume 0, 1 from iterator

asserteq!(band.len(), 2); asserteq!(band.peekfront(), Some(&0)); asserteq!(band.peek_back(), Some(&1));

// just expands, no need to pop first item assert_eq!(band.progress(), None); // consume 3 from iterator

// needs space, pops first item assert_eq!(band.progress(), Some(0)); // consumes 4 from iterator, iterator has no more values

// iterator does not produce more values, progress becomes no-op. No extra capacity is needed, // hence progress does not return any more values. assert_eq!(band.progress(), None); ```