-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
Use of options coupled with the current unwrapping strategy can render the code hard to follow. We should identify where guards could be more appropriate:
fn main() {
let option_1 = Some(42);
let option_2 = Some(32);
// with if..
if let Some(val_1) =option_1 {
if let Some(val_2) = option_2 {
// 2-block depth
println!("{val_1} {val_2}")
}
}
// val_1 & val_2 leave scope...
// Use guards instead
let Some(val_1) = option_1 else { return };
let Some(val_2) = option_2 else { return };
// and values are still in the scope !
println!("{val_1} {val_2}")
}Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers