Take Until

Actions Status

This crate adds the take_until method as an extension for iterators.

Examples

Parsing the next base 128 varint from a byte slice.

```rust use take_until::TakeUntilExt;

let varint = &[0b10101100u8, 0b00000010, 0b10000001]; let int: u32 = varint .iter() .takeuntil(|b| (*b & 0b1000_0000) == 0) .enumerate() .fold(0, |acc, (i, b)| { acc | ((b & 0b01111111) as u32) << (i * 7) }); asserteq!(300, int); ```

Take Until vs Take While (from Standard Library)

```rust use take_until::TakeUntilExt;

fn main() { let items = [1, 2, 3, 4, -5, -6, -7, -8]; let filteredtakewhile = items .intoiter() .takewhile(|x| *x > 0) .collect::>(); let filteredtakeuntil = items .intoiter() .takeuntil(|x| *x <= 0) .collect::>(); asserteq!([1, 2, 3, 4], filteredtakewhile.asslice()); asserteq!([1, 2, 3, 4, -5], filteredtakeuntil.asslice()); } ```

MSRV

The MSRV is 1.56.1 stable.