I was looking the Rust's docs where they introduce this piece of code:
let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};
where the value num is assigned to guess in case of a successful parsing, otherwise the continue statement is executed making the loop to break.
Is it me or this syntax is a bit odd? It feels like we are executing guess = continue. I found this way of writing it more natural:
match guess.trim().parse() {
Ok(num) => let guess: u32 = num,
Err(_) => continue,
};
Am I understanding something wrong? I don't know anything about Rust, so maybe there is an explanation for this.