guard 0.5.2

Macro implementation of RFC 1303: a guard-let-else statement a la Swift
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
#![cfg_attr(feature = "nightly", feature(stmt_expr_attributes))]

#[macro_use] extern crate guard;
use std::env;

fn main() {
    // read configuration from a certain environment variable
    // do nothing if the variable is missing
    guard!(let Ok(foo_value) = env::var("FOO") else { return });

    println!("FOO = {}", foo_value);
}