Crate flow_control

Source
Expand description

Declarative macros for common control-flow use cases such as break, continue, and return.


break_if!(...)

break from a loop if a given predicate evaluates to true.

Supports optionally providing a loop label to specify the loop from which to break.

use flow_control::break_if;

break_if!(predicate);
break_if!(predicate, label);

continue_if!(...)

continue to the next iteration of a loop if a given predicate evaluates to true.

Supports optionally providing a loop label to specify the loop in which to continue.

use flow_control::continue_if;

continue_if!(predicate);
continue_if!(predicate, label);

return_if!(...)

return from a function if a given predicate evaluates to true.

Supports optionally providing a value to return.

use flow_control::return_if;

return_if!(predicate);
return_if!(predicate, value);

Macrosยง

break_if
break from a loop if a given predicate evaluates to true.
continue_if
continue to the next iteration of a loop if a given predicate evaluates to true.
return_if
return from a function if a given predicate evaluates to true.