Macro tankerkoenig::chunk_into_option_arrays

source ·
macro_rules! chunk_into_option_arrays {
    ($input_vec:expr) => { ... };
}
Expand description

Macro to transform a vector into a vector of arrays with a fixed size of 10. The last array will be filled with None if the vector is not divisible by 10.

§Example

use tankerkoenig::chunk_into_option_arrays;

let input_vec = vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"];
let output_vec = chunk_into_option_arrays!(input_vec);

assert_eq!(output_vec.len(), 1);
assert_eq!(output_vec[0], [
    Some("1".to_string()),
    Some("2".to_string()),
    Some("3".to_string()),
    Some("4".to_string()),
    Some("5".to_string()),
    Some("6".to_string()),
    Some("7".to_string()),
    Some("8".to_string()),
    Some("9".to_string()),
    None]);