Hacker News new | ask | show | jobs
by 0x457 1254 days ago
Pretty sure clippy will tell you to rewrite it as:

    if let (Some(x), Some(y)) = (x, y) {
       Some(x + y)
    } else {
       None
    }
`match` in place of `if` looks weird. IMO example with `zip` is better though.
1 comments

Clippy will not complain about the parent's code. It's not really in place of an if; there's four cases there. To be honest, I find 'if let... else None' to be worse looking than the match, though I'm unsure if I truly prefer the zip version to the Some(x? + y?) version.