array
Helpers for slices and Vecs that the standard library does not provide.
Inputs are borrowed slices and results are new Vecs: nothing is mutated. Membership-based
helpers require Eq + Hash.
Install
Section titled “Install”Cargo feature array (enabled by default). To compile only this module:
or in Cargo.toml:
Import path: helpers4::array.
| Item | What it does |
|---|---|
cartesian_product | Returns every pair (x, y) with x from a and y from b, in row-major order. |
count_by | Counts the elements of items per key returned by key. |
difference | Returns the elements of a that are not in b, in a’s order. |
duplicates | Returns the elements that appear more than once in items, each one once, in the order they first appear. |
equals_unordered | Returns true when a and b hold the same elements the same number of times, in any order. |
group_by | Groups the elements of items by the key returned by key. |
interleave | Alternates the elements of a and b, starting with a; the leftover of the longer slice goes at the end. |
intersection | Returns the elements of a that also appear in b, in a’s order. |
intersects | Returns true when a and b share at least one element. |
key_by | Indexes the elements of items by the key returned by key. |
symmetric_difference | Returns the elements present in exactly one of a and b. |
unique | Removes duplicate values, keeping the first occurrence of each and the original order. |
unique_by | Removes elements whose key was already seen, keeping the first of each key in order. |
