macro_rules! match_each_vector_mut {
($self:expr, | $vec:ident | $body:block) => { ... };
}Expand description
Matches on all variants of VectorMut and executes the same code for each variant branch.
This macro eliminates repetitive match statements when implementing operations that need to work uniformly across all mutable vector type variants.
ยงExamples
use vortex_vector::VectorMut;
use vortex_vector::bool::BoolVectorMut;
use vortex_vector::null::NullVectorMut;
use vortex_vector::{VectorMutOps, match_each_vector_mut};
fn reserve_space(vector: &mut VectorMut, additional: usize) {
match_each_vector_mut!(vector, |v| { v.reserve(additional) })
}
// Works with `Null` mutable vectors.
let mut null_vec: VectorMut = NullVectorMut::new(5).into();
reserve_space(&mut null_vec, 10);
assert!(null_vec.capacity() >= 15);
// Works with `Bool` mutable vectors.
let mut bool_vec: VectorMut = BoolVectorMut::from_iter([true, false].map(Some)).into();
reserve_space(&mut bool_vec, 5);
assert!(bool_vec.capacity() >= 7);Note: The reserve method is already provided by the VectorMutOps trait implementation.