Crates.io | block_effects |
lib.rs | block_effects |
version | 0.1.1 |
source | src |
created_at | 2020-09-08 09:29:14.75197 |
updated_at | 2020-09-08 09:39:47.281145 |
description | A macro to chain block effects |
homepage | |
repository | https://github.com/TheNappap/block_effects |
max_upload_size | |
id | 286084 |
size | 7,979 |
With block_effects
, it is possible to chain different block effects with the use of the block!
macro.
This idea was proposed by mcy.
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.
The main purpose of this crate is to minimize indentation for nested blocks.
Unfortunately proc macros also add indentation.
So to fully benefit from this one should not indent the block!
macro or even put the macro braces on the same line as the block.
use block_effects::block;
block!{
if let Some(_) = Some(0) if let Some(_) = Some(0) {
assert!(true);
}
}
let _future = block!{ unsafe async for i in 0..3 match i {
0..=2 => assert!(true),
_ => assert!(false)
} };