Skip to content

Option to split small chains instead of putting on single new line #3538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vimpunk opened this issue May 3, 2019 · 0 comments
Open

Option to split small chains instead of putting on single new line #3538

vimpunk opened this issue May 3, 2019 · 0 comments

Comments

@vimpunk
Copy link

vimpunk commented May 3, 2019

My max_width is 80, using stable version of rustfmt.

E.g. this code I would expect to remain as is:

    let resp = req
        .state()
        .db
        .send(msg)
        .from_err()
        .and_then(|db_resp| match db_resp {
            Ok(roles) => Ok(HttpResponse::Created().json(roles)),
            Err(e) => Err(e),
        });

but is instead formatted like this:

    let resp =
        req.state()
            .db
            .send(msg)
            .from_err()
            .and_then(|db_resp| match db_resp {
                Ok(roles) => Ok(HttpResponse::Created().json(roles)),
                Err(e) => Err(e),
            });

Smaller chains are sometimes kept as a single line but put on a new line, like so:

                let login_ids: Vec<_> =
                    result.active_members.iter().map(|m| m.login_id).collect();

It would be great to have an option to specify that I prefer splitting up such chains instead of keeping them together as much as possible. Apologies if there is already an option for this and I've missed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants