iter_cartesian 0.1.0

A Cartesian product iterator with double-ended iteration and O(1) length queries.
Documentation
# iter_cartesian


A chainable `.cartesian()` adapter that yields every `(a, b)` pair from two iterators, the iterator equivalent of a nested loop.

## Usage

```rust
use iter_cartesian::CartesianExt;

// collect every (a, b) pair
let pairs: Vec<_> = (0..m).cartesian(0..n).collect();

// iterate in reverse
let rev_pairs: Vec<_> = (0..m).cartesian(0..n).rev().collect();

// O(1) overrides
let item = (0..m).cartesian(0..n).nth(k);
let last = (0..m).cartesian(0..n).last();
let total = (0..m).cartesian(0..n).count();
```

## Features


- Chainable `.cartesian()` method on any double-ended exact-size iterator
- Full `DoubleEndedIterator` support, interleave `next()` and `next_back()` correctly
- O(1) `len`, `nth`, and `count` via overridden iterator methods
- `TrustedLen` and `FusedIterator` implementations

## Benchmarks


All O(1) operations confirmed flat across input sizes. Collection is ~54% faster than `flat_map`, with significantly lower variance.

| Benchmark | Time |
|---|---|
| `len`, 10 × 10 | 455 ps |
| `len`, 1000 × 1000 | 449 ps |
| `len`, 100000 × 100000 | 447 ps |
| `nth`, jump 10 | 16.6 ns |
| `nth`, jump 100,000 | 16.9 ns |
| `nth`, jump 1,000,000 | 16.6 ns |
| `collect`, 1000 × 1000 | 2.48 ms |
| `flat_map` equivalent | 5.44 ms (±1.54 ms) |

## Alternatives


- [`itertools::iproduct!`]https://docs.rs/itertools/latest/itertools/macro.iproduct.html, macro-based, no `DoubleEndedIterator`
- [`flat_map`]https://doc.rust-lang.org/std/iter/struct.FlatMap.html, no `rev()`, no O(1) `len`, ~54% slower to collect

## License

MIT OR Apache-2.0