-
Notifications
You must be signed in to change notification settings - Fork 56
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
Types #15
Comments
Single line formatting
Parentheses used in types should not be surrounded by whitespace, e.g., Macros in type position will be covered elsewhere. Line breaksAvoid breaking lines in types where possible. Prefer breaking at outermost scope, e.g., prefer
to
Function types may be broken following functions Generic types may be broken following the rules for generics types with
Alternative, block indent, before
Option, require or allow block indent break after
Question, with regard to breaking generic types, I prefer visual indent since I think it is harder to mentally line up block indent with a nested type, consider:
For me, this is hard to read since the block indented generics look like additional type params of the function, rather than type params of the type. C.f.,
|
For tuples, please note that you need a trailing comma for a one-tuple. As in other cases, I would strongly prefer to use block-indent. The visual-indent case you posted at the end of your comment exhibits exactly the rightward-drift problem that visual indent tends to cause and block indent tends to avoid; I find it much less readable. That said, I think your block-indent example became unreadable because you didn't follow your stated rule of "break the outermost type first". It should look like this, which I'd consider quite readable. (The extra newlines may seem excessive, but remember that this will only occur with much longer identifiers than those used in this example, and that this particular case would likely get much more readable with a fn foo<
T: ALongType<
With,
Long,
TypeArguments,
>,
>(
x: T,
y: AnotherType
) {
...
} Regarding formatting of |
I think this needs a more general case of that rule - there is not a single, nested type being broken here, but we want to break outer components of the function signature, before inner components. That seems like a fine rule to have and I agree that your formatting looks fine and also should be rare.
agreed |
This has been in FCP for long enough, I think we're done. |
We've changed our process: rather than requiring a full RFC, a PR to close this issue only requires making the changes discussed here to the style guide. You can see more details about the process in the readme for this repo. If you'd like to help with this work, let me know, I'd be very happy to help you help us. |
No description provided.
The text was updated successfully, but these errors were encountered: