You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, there are currently 474 issues|PRs here that contain "if let", so I hope I'm not duplicating something already discussed.
This idea is quite close to #929, but instead of allowing to &&lets, it'd allow to && with a bool.
Basically, the idea looks like this:
ifletSome(x) = y && x > 42{println!("foo");}else{println!("bar");}// Would be equivalent to:ifletSome(x) = y {if x > 42{println!("foo");}else{println!("bar");}}else{println!("bar");}
This pattern is something that frequently occurred to me, and I'm finding it painful to always look for workarounds.
The constraints to this pattern would be:
Only && could be used after a let, especially if a || is wanted it must be as a child node of the && (required so that the RHS could be evaluated with the let binding in scope)
For the time being, it is restricted to one let and one or more && with bools, leaving ideas like if let Some((a, b)) = x && a > 42 && let Some(c) = b.unwrap() for later (modulo Support && in if let expressions #929)
First, there are currently 474 issues|PRs here that contain "if let", so I hope I'm not duplicating something already discussed.
This idea is quite close to #929, but instead of allowing to
&&lets, it'd allow to&&with abool.Basically, the idea looks like this:
This pattern is something that frequently occurred to me, and I'm finding it painful to always look for workarounds.
The constraints to this pattern would be:
if let Some((a, b)) = x && a > 42 && let Some(c) = b.unwrap()for later (modulo Support && in if let expressions #929)What do you think about this idea?