News for hackers. Stuff that matters.
Re:Falling in love with Rust by Spiritus on Wednesday September 19, 2018 @03:14AM (#18022377)
That's nice and all. But then you have abominations like this:

    state
        .db
        .send(Queries::GetTopTenHottestYears)
        .from_err()
        .and_then(move |res| {
            result.push(res.unwrap());
            state
                .db
                .send(Queries::GetTopTenColdestYears)
                .from_err()
                .and_then(move |res| {
                    result.push(res.unwrap());
                    state
                        .db
                        .send(Queries::GetTopTenHottestMonths)
                        .from_err()
                        .and_then(move |res| {
                            result.push(res.unwrap());
                            state
                                .db
                                .send(Queries::GetTopTenColdestMonths)
                                .from_err()
                                .and_then(move |res| {
                                    result.push(res.unwrap());
                                    fut_ok(result)
                                })
                        })
                })
        })
        .and_then(|res| Ok(HttpResponse::Ok().json(res)))
        .responder()
https://github.com/actix/examples/blob/master/async_db/src/m...

My suspicion is the people do this to avoid "variable does not live long enough" type errors.

Re:Falling in love with Rust by gamegoblin on Wednesday September 19, 2018 @03:36AM (#18022473)
I believe that is written that way because it's using futures. Once async/await lands this year, all of the futures combinator madness goes away.
Re:Falling in love with Rust by thibran on Wednesday September 19, 2018 @04:30AM (#18022739)
The code could use closures to split the expression or define local functions on the bottom of the surrounding function (a.k.a Haskell style). This would increase readability a lot.

Example: https://play.rust-lang.org/?gist=7ea1a39971399d0429f0369cb9e...

Re:Falling in love with Rust by drudru11 on Sunday September 23, 2018 @04:01AM (#18049974)
This is called the 'pyramid of doom' in the nodejs circles