Description
Discussion for spaces_within_parenthesized_items
configuration option. Implemented by #5434.
This option enforces consistent spacing directly inside of parentheses, by putting one space to the right of '(' and to the left of ')' in parenthesized items, such as function calls:
fn ipsum_lorem(arg1: usize, arg2: usize, arg3: usize)
to
fn ipsum_lorem( arg1: usize, arg2: usize, arg3: usize )
I do believe there are cases where having these spaces do improve readability, for example on calls:
ipsum_lorem<T>(dolor_amet<T>(string));
to
ipsum_lorem<T>( dolor_amet<T>( string ) );
Although I do understand that at the end of the day it is very subjective.
This option goes against some behaviours of the Rust Style Guide:
Single line calls and tuple literals.
Discussion topics:
- Should tuple literals and struct tuple literals follow this rule as well?
(a, b, c)
Foo(a, b)
to
( a, b, c )
Foo( a, b )
- What if there's comments and there's no parenthesized item, should spaces be added?
foo(/* comment */);
to
foo( /* comment */ );
- What about attributes?
#[cfg(test)]
to
#[cfg( test )]
- Patterns and grouping parentheses ?
(1 * ((2 + 3) * 4)
to
( 1 * ( ( 2 + 3 ) * 4 ) ) // I think grouping parentheses should not be included.
- Is there a possibility of having the same rule for other symbols such as
<>
and[]
? You could write an array like this[ 1, 2, 3, 4, 5 ]
andvec![ 1, 2, 3, 4 ]
.
Cheers!