fera_graph/traverse/
control.rs1#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
6pub enum Control {
7 Continue,
8 Break,
9}
10
11impl From<()> for Control {
12 fn from(_: ()) -> Self {
13 Control::Continue
14 }
15}
16
17pub fn continue_if(cond: bool) -> Control {
18 if cond {
19 Control::Continue
20 } else {
21 Control::Break
22 }
23}
24
25pub fn break_if(cond: bool) -> Control {
26 if cond {
27 Control::Break
28 } else {
29 Control::Continue
30 }
31}
32
33macro_rules! return_unless {
34 ($e:expr) => {
35 if $e == Control::Break {
36 return Control::Break;
37 }
38 };
39}
40
41macro_rules! break_unless {
42 ($e:expr) => {
43 if $e == Control::Break {
44 break;
45 }
46 };
47}