4 ms·
Early exit code would be easier to write if Rust supported guard let.
by gardaani 4y ago
Early exit code would be easier to write if Rust supported guard let.
- klodolph 4y agoLike this? if let Ok(x) = my_func() { // ... } Or do you mean something else?
- veber-alex 4y agoits coming soon, already available on nightly. let Some(x) = foo() else { return 42 };
- inferiorhuman 4y agoI'd suggest that something like that is already achievable by having foo return an Option and combining it with unwrap_or.