[][src]Macro block_effects::block

block!() { /* proc-macro */ }

The block! macro is used to mark blocks with chained block effects.

The following block effects can be chained: unsafe, async, if, match, loop, while and for. Additionally if let and while let are also possible.

Remarks

Some combinations of chaining effects just don't work. Here are some exceptions to keep in mind:

  • Ignoring unsafe, an async should be in front of the chain, otherwise the returned Future can't be used.
  • A match should be the last in line, because the body of a match block is different.
  • An else block can only be used if the starting block effect is an if.

Example

An Example with an if let, for, loop and match effects:

 use block_effects::block;

 block!{
     if let Some(_) = Some(0) for i in 0..4 loop match i {
         0..=3 => { 
             assert!(true); 
             break;
         },
         _ => assert!(false)
     } else {
         assert!(false);
     }
 }