[−][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
, anasync
should be in front of the chain, otherwise the returnedFuture
can't be used. - A
match
should be the last in line, because the body of amatch
block is different. - An
else
block can only be used if the starting block effect is anif
.
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); } }