Macro apply_to_warray

Source
macro_rules! apply_to_warray {
    ( $warray:expr, $function:expr ) => { ... };
}
Expand description

Apply an expression to any variant of a WArray.

Each variant of a WArray holds a different type, so there is no way to generically apply an identical expression to all variants. However, sometimes we don’t care about the type, and just want to apply an expression with the same syntax and analogous semantics regardless (e.g., we want to know the length). This macro does just that. This obviously means the expression must resolve to valid code when called on any of the particular types. The expression is applied as a function call.

E.g., len is defined as pub fn len(&self) -> usize { apply_to_warray!(self, Vec::len) }