Crates.io | dyn-product |
lib.rs | dyn-product |
version | 0.1.0 |
source | src |
created_at | 2023-02-09 06:43:37.27414 |
updated_at | 2023-02-09 06:43:37.27414 |
description | A crate that creates cartesian product of size determined at runtime. |
homepage | |
repository | https://github.com/niumlaque/dyn-product |
max_upload_size | |
id | 780552 |
size | 13,432 |
A crate that creates cartesian product of size determined at runtime.
If the size is determined at compile time, it is better to use itertools::iproduct!
.
Add dependency to your Cargo.toml
.
[dependencies]
dyn-product = "0.1"
use dyn_product::DynProduct;
let data = vec![
vec!["GroupA-1", "GroupA-2", "GroupA-3"],
vec!["GroupB-1", "GroupB-2"],
vec!["GroupC-1", "GroupC-2", "GroupC-3", "GroupC-4"],
];
for item in DynProduct::from(&data) {
println!("{:?}", item);
}
output:
["GroupA-1", "GroupB-1", "GroupC-1"]
["GroupA-1", "GroupB-1", "GroupC-2"]
["GroupA-1", "GroupB-1", "GroupC-3"]
["GroupA-1", "GroupB-1", "GroupC-4"]
["GroupA-1", "GroupB-2", "GroupC-1"]
["GroupA-1", "GroupB-2", "GroupC-2"]
["GroupA-1", "GroupB-2", "GroupC-3"]
["GroupA-1", "GroupB-2", "GroupC-4"]
["GroupA-2", "GroupB-1", "GroupC-1"]
["GroupA-2", "GroupB-1", "GroupC-2"]
["GroupA-2", "GroupB-1", "GroupC-3"]
["GroupA-2", "GroupB-1", "GroupC-4"]
["GroupA-2", "GroupB-2", "GroupC-1"]
["GroupA-2", "GroupB-2", "GroupC-2"]
["GroupA-2", "GroupB-2", "GroupC-3"]
["GroupA-2", "GroupB-2", "GroupC-4"]
["GroupA-3", "GroupB-1", "GroupC-1"]
["GroupA-3", "GroupB-1", "GroupC-2"]
["GroupA-3", "GroupB-1", "GroupC-3"]
["GroupA-3", "GroupB-1", "GroupC-4"]
["GroupA-3", "GroupB-2", "GroupC-1"]
["GroupA-3", "GroupB-2", "GroupC-2"]
["GroupA-3", "GroupB-2", "GroupC-3"]
["GroupA-3", "GroupB-2", "GroupC-4"]