[][src]Macro wlroots::with_handles

macro_rules! with_handles {
    ([($handle_name: ident: $unhandle_name: block)] => $body: block) => { ... };
    ([($handle_name1: ident: $unhandle_name1: block),
      ($handle_name2: ident: $unhandle_name2: block),
      $($rest: tt)*] => $body: block) => { ... };
    ([($handle_name: ident: $unhandle_name: block), $($rest: tt)*] => $body: block) => { ... };

A convenience macro designed for use with Handle types.

This allows you to avoid the rightward drift of death that is often found with heavily nested callback systems.

Any HandleResults are flattened and the first one encountered is immediately returned before any of the $body code is executed.

Order of evaluation is from left to right. It is possible to refer to the previous result, as commonly found in Lisp's let* macro.

An example of simple use:

This example is not tested
with_handles!([(compositor: {compositor}),
   (output: {&mut result.output_handle})] => {

A more complex use:

This example is not tested
with_handles!([(shell: {shell_handle}),
   // Notice how we use the previous result to get the surface.
   (surface: {shell.surface_handle})] => {