Skip to main content

repeat_until

Macro repeat_until 

Source
macro_rules! repeat_until {
    ($name:ident<$T:ty> = {
        counter: $counter:expr,
        condition: $condition_var:expr,
        max_iterations: $max:expr,
        ops: [$($op:expr),+ $(,)?]
    }) => { ... };
    ($name:ident<$T:ty> -> $strategy:ident = {
        counter: $counter:expr,
        condition: $condition_var:expr,
        max_iterations: $max:expr,
        ops: [$($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 while-loop op type with condition-based iteration The condition is checked from a boolean variable in the dry context Internal control flags use unique UUIDs to prevent conflicts in nested loops Usage:

// Returns Vec<T> (default)
repeat_until! {
    ProcessUntilDone<String> = {
        counter: "iteration",
        condition: "should_continue",  // Boolean variable in dry context
        max_iterations: 100,           // Safety limit
        ops: [ProcessOp::new(), CheckOp::new()]
    }
}

// Returns T using last result
repeat_until! {
    ProcessUntilDone<String> -> last = {
        counter: "iteration",
        condition: "should_continue",
        max_iterations: 100,
        ops: [ProcessOp::new(), CheckOp::new()]
    }
}