Sha256: 4b1c394e44a9ef9bc0de707ae080b45803db722f79834c20f15b826d7c3f1f2e

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

use itertools::Itertools;
use itertools::{put_back, put_back_n};

#[test]
fn peeking_take_while_peekable() {
    let mut r = (0..10).peekable();
    r.peeking_take_while(|x| *x <= 3).count();
    assert_eq!(r.next(), Some(4));
}

#[test]
fn peeking_take_while_put_back() {
    let mut r = put_back(0..10);
    r.peeking_take_while(|x| *x <= 3).count();
    assert_eq!(r.next(), Some(4));
    r.peeking_take_while(|_| true).count();
    assert_eq!(r.next(), None);
}

#[test]
fn peeking_take_while_put_back_n() {
    let mut r = put_back_n(6..10);
    for elt in (0..6).rev() {
        r.put_back(elt);
    }
    r.peeking_take_while(|x| *x <= 3).count();
    assert_eq!(r.next(), Some(4));
    r.peeking_take_while(|_| true).count();
    assert_eq!(r.next(), None);
}

#[test]
fn peeking_take_while_slice_iter() {
    let v = [1, 2, 3, 4, 5, 6];
    let mut r = v.iter();
    r.peeking_take_while(|x| **x <= 3).count();
    assert_eq!(r.next(), Some(&4));
    r.peeking_take_while(|_| true).count();
    assert_eq!(r.next(), None);
}

#[test]
fn peeking_take_while_slice_iter_rev() {
    let v = [1, 2, 3, 4, 5, 6];
    let mut r = v.iter().rev();
    r.peeking_take_while(|x| **x >= 3).count();
    assert_eq!(r.next(), Some(&2));
    r.peeking_take_while(|_| true).count();
    assert_eq!(r.next(), None);
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
wasmtime-18.0.3 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-17.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-17.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-16.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-15.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-15.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-14.0.4 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-14.0.3 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-14.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-14.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-13.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-12.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-12.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-11.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-10.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-10.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-9.0.4 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-9.0.1 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-8.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs
wasmtime-7.0.0 ./ext/cargo-vendor/itertools-0.10.5/tests/peeking_take_while.rs