-
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
struct and tuple literals #64
Comments
structsSingle line version: Mutli-line version:
Note space before Use the mutli-line version if the literal does not fit in the line, if the fields are not short (see #47), or if any of the field sub-expressions cover multliple lines. Otherwise use the single-line version. |
tuple variantsUnit variants are trivial. Struct variants should follow the guidelines for structs. Tuple variants should follow the guidelines for function calls. |
Functional record updateDoes not get a trailing comma, is otherwise treated like any other field. There is no space after the
|
I kinda dislike this, up to the point that it was my major friction point with rustfmt. I don't know how others feels about this, but I am commenting here so that this is taken in consideration =). I would be happy with this not being the default but being configurable. To me, this have way to many spaces. I would prefer A version with a space before the left brace looks OK to me too: |
@Luthaf for a counterpoint, the most immediate predecessor for this is JavaScript's object types. It's common there to write the same kind of short structure that way there: const field1 = 'whatever';
const field2 = 42;
const path = { field1, field2 }; I'd also note that this feels quite different from construction in C++ to me – and I want to be made more actively aware that there isn't any function call happening! – but that's just me. I think the specified default is a good default, but I certainly wouldn't be hostile to its being configurable either. |
On May 16, 2017 1:47:57 AM PDT, Luthaf ***@***.***> wrote:
> Single line version: Path { field1, field2 }. Note spaces before and
after {, before }, no trailing comma
I kinda dislike this, up to the point that it was my major friction
point with rustfmt. I don't know how others feels about this, but I am
commenting here so that this is taken in consideration =). I would be
happy with this not being the default but being configurable.
To me, this have way to many spaces. I would prefer `Path{field1,
field2}`, without the spaces. The only rationalisation I can get for
this is that inline struct literals feels like constructors in C++,
with the braces playing the role of parenthesis.
A version with a space before the left brace looks OK to me too: `Path
{field1, field2}`, and it would look more like the multiline version.
I find it jarring to see anything right next to a curly brace like this. And struct constructors have obvious analogues in other languages, using similar syntax.
|
No description provided.
The text was updated successfully, but these errors were encountered: