| Crates.io | cartesian_array_product |
| lib.rs | cartesian_array_product |
| version | 1.1.1 |
| created_at | 2023-08-06 09:21:55.817452+00 |
| updated_at | 2023-08-07 12:38:23.372256+00 |
| description | Arrays of the cartesian product of a set of items. |
| homepage | |
| repository | https://github.com/Odilf/cartesian_array_product |
| max_upload_size | |
| id | 937015 |
| size | 10,345 |
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.
Add this crate as a dependency:
cargo add cartesian_array_product
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.
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 ðŸ˜ðŸ˜ðŸ˜)