Skip to content
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

Add field-access-same-line config option #4889

Closed
wants to merge 2 commits into from

Conversation

kangalio
Copy link

@kangalio kangalio commented Jul 4, 2021

Resolves #3641.

Adds a new configuration option field-access-same-line, which puts subsequent field accesses in chains on the same line. For example:

self.serializer
    .writer
    .write_u32::<LittleEndian>(array_offset)?;

turns into

self.serializer.writer
    .write_u32::<LittleEndian>(array_offset)?;

A more elaborate test case is in the tests directory.

Field accesses with indexing (e.g. self.field[5].field) in them are not correctly put on a single line, because, apparently, rustfmt splits chains into multiple separate Chain objects when there is indexing in it. I don't know the motivation behind this and I think it's too complicated for me as a newcomer to the codebase to fix.

@calebcartwright
Copy link
Member

See #4888 (comment) for more info

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

Successfully merging this pull request may close these issues.

Allow field access on same line when breaking long chain?
2 participants