macro_rules! replace {
($slots:expr, { $($index:expr => $value:expr,)* }) => { ... };
($slots:expr, { $($index:expr => $value:expr),* }) => { ... };
}Expand description
Replaces the values at specified indices in the slots with the provided values.
This macro allows replacing multiple values in the slots at once. It takes a set of index-value pairs enclosed in curly braces.
§Examples
use slots_slice::replace;
let mut slots: [Option<u32>; 5] = [None; 5];
slots_slice::replace!(slots, { 1 => 42, 3 => 99 });
assert_eq!(slots, [None, Some(42), None, Some(99), None]);§Panics
As this macro uses ops::Index, it may panic if any index is out of bounds.