You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way (planned) to distinguish between a parameter list, let statement, and other uses of the type annotation colon?
I would like to have my code formatted so that
let my_string :String = "hello".to_string();
has a space before the colon, because the colon feels like it separates the type from the identifier.
But I would like to have no space before the colon here:
fnfoo(my_arg:String,another_arg:&str){}
because the type belongs to its preceeding argument and it feels like it is too close to the next parameter when I have the space before the colon.
Of course, tastes may vary. And it's not that important to be able to distinguish these cases. But I'd like to, if it was easily doable.
My thoughts as well, but to say it in one rule: The colon belongs with the type when the type is optional. Because they are added or removed together. Just like in UML.
I can think of 3 uses of colon:
Before an optional type (those let statements)
Before an obligatory type (such as function and struct parameters)
Before a value (in designated initializers)
I would also remove the space after the colon (#3366) by the exact same rule, but maybe that's just me.
Tracking issue for unstable option: space_before_colon
The text was updated successfully, but these errors were encountered: