array_of

Macro array_of 

Source
macro_rules! array_of {
    ($max:expr, { $($index:expr => $value:expr,)* }) => { ... };
    ($max:expr, { $($index:expr => $value:expr),* }) => { ... };
}
Expand description

Creates an array of Option<T> with specified values at corresponding indices.

This macro allows creating an array of Option<T> with provided values at specified indices. The array size is determined by the first argument specified. Useful for large slots.

ยงExamples

use slots_slice::array_of;

let slots: [Option<char>; 5] = slots_slice::array_of!(5, { 1 => 'a', 3 => 'b' });

assert_eq!(slots, [None, Some('a'), None, Some('b'), None]);