I was reading through the book, and stumbled upon chapter 6.3: Concise Control Flow with if let
I read the part about "if let" seven times or so, but I can still not wrap my head around why this syntax is like that.
I feel that I can probably apply the syntax to have result, but that unless I understand why it is the way it is, I'll never be able to memorise and integrate the concept in my brain.
Instead of
if let Some(3) = some_u8_value {
println!("three");
}
I guess I would expect something like
if some_u8_value <matches> Some(3) {
println!("three");
}
or
if Some(3) <matches> some_u8_value {
println!("three");
}
where <matches>
could be any keyword, really.
I have been doing some more reading, and then found the chapter 18.1: All the Places Patterns Can Be Used
I have to say, it did not help me understand at all why the if let syntax is structured the way it is.
Did anyone also struggle with it, and found either a simple explanation, or some article "if let syntax for dummy" that helped you wrap your head around the concept?
Thanks!