#zip #increasing #indices #sum #breadth-first #guaranteeing #monotonically

macro breadth-first-zip-macros

Breadth-first zip guaranteeing a monotonically increasing sum of indices

5 unstable releases

0.3.0 Jul 2, 2023
0.2.2 Jul 1, 2023
0.2.1 Jul 1, 2023
0.2.0 Jul 1, 2023
0.1.0 Jun 29, 2023

#8 in #increasing

Download history 4/week @ 2024-02-18 29/week @ 2024-02-25 7/week @ 2024-03-03 9/week @ 2024-03-10 3/week @ 2024-03-17 3/week @ 2024-03-24 66/week @ 2024-03-31

82 downloads per month
Used in 3 crates (via breadth-first-zip)

MPL-2.0 license

23KB
539 lines

Breadth-first zip

Property-tested and verified to return every possible value exactly one in a strictly increasing sum of indices.

Why?

For whenever you have a multiple iterators and want to cover every possible value from overall smallest to largest.

E.g. for three instances of 0..3, you'd get this:

0 0 0 # sum = 0
0 0 1 # sum = 1
0 1 0
1 0 0
0 0 2 # sum = 2
0 1 1
0 2 0
1 0 1
1 1 0
2 0 0
0 1 2 # sum = 3
0 2 1
1 0 2
1 1 1
1 2 0
2 0 1
2 1 0
0 2 2 # sum = 4
1 1 2
1 2 1
2 0 2
2 1 1
2 2 0
1 2 2 # sum = 5
2 1 2
2 2 1
2 2 2 # sum = 6

Inputs can be any non-empty iterator, even combining different sizes.


lib.rs:

Automatically implement BreadthFirstIterator for tuples up to a finite but huge size.

Dependencies

~320–770KB
~18K SLoC