fmt-rfcs icon indicating copy to clipboard operation
fmt-rfcs copied to clipboard

Improve formatting of ranges whose start/end contain binary operators

Open joshtriplett opened this issue 1 year ago • 1 comments

An example:

count_hash + 2..s.len() - count_hash - 1

The spacing is confusing and doesn't match the precedence.

I think we should format this like:

(count_hash + 2)..(s.len() - count_hash - 1)

Note that I only think we should parenthesize endpoints when needed for clarity, so for instance:

count_hash..(s.len() - count_hash - 1)

joshtriplett avatar Jan 07 '25 11:01 joshtriplett

Yes pleeeeaassseee, that would be such a nice improvement!

Licenser avatar Jan 07 '25 16:01 Licenser