The code below will print a
and b
, but I'd like it to print only a
.
Looking at the line if let (true, None) = (a(), b())
is there any way to make b()
be called lazily, ie, only if a()
evaluates to true
as the destructuring expects?
I know I could chain match/if, but I really wanted to be able to match a pattern this way. It would bring a lot of clarity to the code I'm working in. I'd like to propose this feature.
fn main() {
if let (true, Some(_)) = (a(), b()) {
println!("c");
}
}
fn a() -> bool {
println!("a");
return false;
}
fn b() -> Option<i32> {
println!("b");
return Some(33);
}