Skip to main content

batch

Macro batch 

Source
macro_rules! batch {
    ($name:ident<$T:ty> = [$($op:expr),+ $(,)?]) => { ... };
    ($name:ident<$T:ty> -> $strategy:ident = [$($op:expr),+ $(,)?]) => { ... };
    (@strategy all) => { ... };
    (@strategy last) => { ... };
    (@strategy first) => { ... };
    (@strategy merge) => { ... };
    (@strategy unit) => { ... };
    (@impl $name:ident<$T:ty> -> all) => { ... };
    (@impl $name:ident<$T:ty> -> last) => { ... };
    (@impl $name:ident<$T:ty> -> first) => { ... };
    (@impl $name:ident<$T:ty> -> unit) => { ... };
    (@impl $name:ident<$T:ty> -> merge) => { ... };
}
Expand description

Create a named batch op type with flexible return types and aggregation Usage:

// Returns Vec<T> (default behavior)
batch! {
    ProcessingPipeline<String> = [
        ValidationOp::new(),
        TransformOp::new()
    ]
}

// Returns T using last result
batch! {
    ProcessingPipeline<String> -> last = [
        ValidationOp::new(),
        TransformOp::new()
    ]
}

// Returns () ignoring all results
batch! {
    ProcessingPipeline<()> -> unit = [
        SideEffectOp::new(),
        LoggingOp::new()
    ]
}