cartesian_array_product

Crates.iocartesian_array_product
lib.rscartesian_array_product
version1.1.1
sourcesrc
created_at2023-08-06 09:21:55.817452
updated_at2023-08-07 12:38:23.372256
descriptionArrays of the cartesian product of a set of items.
homepage
repositoryhttps://github.com/Odilf/cartesian_array_product
max_upload_size
id937015
size10,345
(Odilf)

documentation

https://docs.rs/cartesian_array_product

README

cartesian-array-product

This crate provides a macro to generate an array with the cartesian product of multiple arrays.

It is meant to be usable in const contexts.

Usage

Add this crate as a dependency:

cargo add cartesian_array_product

Example

use cartesian_array_product::cartesian_array;

let product = cartesian_array!([1, 2], [3, 4]);
let expected = [
    (1, 3),
    (2, 3),
    (1, 4),
    (2, 4),
];

assert_eq!(product, expected);

See https://docs.rs/cartesian_array_product for further info.

Caveat

This macro doesn't allow trailing commas in the input arrays. This is because $($var:whatever),* doesn't match trailing commas, and adding manually $($var:whatever),* $(,)? is too much repetation for a thing that, honestly, isn't that important. (maybe i'm just writing this to convience myself because i hate not having trailing commas 😭😭😭)

Commit count: 26

cargo fmt