News for hackers. Stuff that matters.
Re:Optional If Expressions by kmarc on Saturday April 15, 2023 @05:06AM (#35578910)
If anyone wondering what that means for "optional ifs":

        if let Some(new_variable) = method_that_returns_optional_value {
            println!("value: {new_variable}")
        } else {
            println!("{new_variable} is not in scope, this wont't compile");
        }
I find it powerful. "if-let" and "while-let" are part of the language. OTOH rustaceans are happy with and constantly reasoning (constantly fighting the borrowchecker?) about scopes and if a variable / it's intended value is accessible at a certain line of the source code.

There are no comments on this comment yet.