Sha256: f459f36d54f5d475b2b2e83f5a1c98109c15062756ae822fa379486f3eeed666

Contents?: true

Size: 951 Bytes

Versions: 25

Compression:

Stored size: 951 Bytes

Contents

use itertools::Itertools;

struct PanickingCounter {
    curr: usize,
    max: usize,
}

impl Iterator for PanickingCounter {
    type Item = ();

    fn next(&mut self) -> Option<Self::Item> {
        self.curr += 1;

        assert_ne!(
            self.curr, self.max,
            "Input iterator reached maximum of {} suggesting collection by adaptor",
            self.max
        );

        Some(())
    }
}

fn no_collect_test<A, T>(to_adaptor: T)
    where A: Iterator, T: Fn(PanickingCounter) -> A
{
    let counter = PanickingCounter { curr: 0, max: 10_000 };
    let adaptor = to_adaptor(counter);

    for _ in adaptor.take(5) {}
}

#[test]
fn permutations_no_collect() {
    no_collect_test(|iter| iter.permutations(5))
}

#[test]
fn combinations_no_collect() {
    no_collect_test(|iter| iter.combinations(5))
}

#[test]
fn combinations_with_replacement_no_collect() {
    no_collect_test(|iter| iter.combinations_with_replacement(5))
}

Version data entries

25 entries across 25 versions & 1 rubygems

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