event_flow

Macro event_flow 

Source
macro_rules! event_flow {
    (log $n:ident: return $x:expr) => { ... };
    (log $n:ident: break $l:lifetime $x:expr) => { ... };
    (log $n:ident: $x:expr) => { ... };
    (break $l:lifetime $x:expr) => { ... };
    (return $x:expr) => { ... };
    ($x:expr) => { ... };
}
Expand description

Tries to unify the currently 3 flow! constructs.

  • flow!(expr) -> event_flow!(return expr) The non Result case stays gets a return. It’s rather uncommon to not have a Result during event-handling, so this should be fine.
  • try_flow!(expr) -> event_flow!(expr) This becomes the main branch.
  • break_flow!('x: expr) -> event_flow!(break 'x expr) This now matches actual rust syntax, which is good for rustfmt. The break 'x is stripped and reapplied after result-conversion.

_

I’ll try this out… If it’s fine I’ll leave the other macros with a discouraging remark and promote this variant.

note: of course the default is diametrical when you write library code for a new widget. as usual :-|. stick with it though as libraries should be used more often than written.