dyn-product

Crates.iodyn-product
lib.rsdyn-product
version0.1.0
sourcesrc
created_at2023-02-09 06:43:37.27414
updated_at2023-02-09 06:43:37.27414
descriptionA crate that creates cartesian product of size determined at runtime.
homepage
repositoryhttps://github.com/niumlaque/dyn-product
max_upload_size
id780552
size13,432
Niumlaque (niumlaque)

documentation

README

DYN-PRODUCT

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!.

Usage

Add dependency to your Cargo.toml.

[dependencies]
dyn-product = "0.1"

Example

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"]
Commit count: 10

cargo fmt