Skip to content

Feature request: chain_tokens instead of chain_width #6478

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

Closed
RandomInsano opened this issue Feb 14, 2025 · 1 comment
Closed

Feature request: chain_tokens instead of chain_width #6478

RandomInsano opened this issue Feb 14, 2025 · 1 comment

Comments

@RandomInsano
Copy link

Hey there! I've started handing over my code to rustfmt and it's working almost perfectly but I find that chain_width isn't doing what I'd like.

In general, I split chains when the number of function calls is greater than 3 as it helps me better understand what the chunk of code is doing at a glance. If the chain is only two functions but their names are absurdly long it's clear enough. Here's an example from my own codebase where I'm hitting this sort of thing. I'm not sure if others are hitting this as well, but I'm finding it's making my code less readable in a way I can't easily fix.

let authors = env!("CARGO_PKG_AUTHORS")
    .split(":")
    .map(|x| x.to_string())
    .collect(),

Now:

let authors = env!("CARGO_PKG_AUTHORS").split(":").map(|x| x.to_string()).collect(),

There also doesn't seem to be a way to disable it? So my option is careful inspection.

@ytmimi
Copy link
Contributor

ytmimi commented Feb 14, 2025

Similar feature requests have been asked for in the past (#3538, #2263). Your best bet is to use #[rustfmt::skip] if you need more control over chain formatting for now.

@ytmimi ytmimi closed this as completed Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants