News for hackers. Stuff that matters.
Re:Things Rust shipped without by veddan on Friday July 03, 2015 @03:57PM (#9827618)
I think that the "expression-style" return looks good for short and "expression-like" function.

Good

    fn inc(a: u32) -> u32 { a + 1 }
    fn foo(a: u32, b: u32) -> u32 { let x = a + b; a * x }
Bad

    fn bar(...) -> bool {
        let mut success = false;
        let conn = getConnection();
        ...
        if x > y {
            return false;
        } else if z < q {
            success = false;
        }
        foo.barify(x, y);
        ...
        success
    }
It looks especially bad when the function has multiple early returns, and then the final return looks different.
Re:Things Rust shipped without by ewillbefull on Friday July 03, 2015 @08:03PM (#9828562)
This could easily be added as a lint to the codebase.
Re:Things Rust shipped without by Eerie on Friday July 03, 2015 @04:26PM (#9827748)
Sheesh, it's such a little thing. "success" vs "return success;"
Re:Things Rust shipped without by cmrx64 on Friday July 03, 2015 @06:13PM (#9828209)
Doesn't work when you're not returning from a function (ie, EVERY OTHER PLACE a block can appear)