1 unstable release
0.1.0 | Jan 27, 2019 |
---|
#15 in #chains
3KB
iff.rs
A macro for if / if let chains until RFC 2497 is implemented.
Usage
use iff::iff;
fn go(var: Option<Vec<i32>>) {
print!("{:?}", var);
iff! {
let Some(x) = var,
let [y, _] = &*x,
*y == 0 => {
print!(" => ok")
}
}
println!("");
}
fn main() {
go(None);
go(Some(vec![]));
go(Some(vec![0]));
go(Some(vec![0, 1]));
go(Some(vec![0, 1, 2]));
}
Output:
None
Some([])
Some([0])
Some([0, 1]) => ok
Some([0, 1, 2])