-
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 union declarations #30
Comments
Single-line tuple structs are already covered in the guide: https://github.com/rust-lang-nursery/fmt-rfcs/blob/master/guide/guide.md#tuples-and-tuple-structs |
I prefer: struct Foo /* <- must be on one line */ { /* <- on the first line if it fits, otherwise pull it down */
b: B, /* <- indented once, must end with a trailing comma */
long_name:
LongName, /* <- if required, pull the type name down to the next line and indent again */
} /* <- on it's own line */ |
And to clarify - a trailing comma on the last field? |
@nrc Yes. That avoids having to add a comma when adding another field, or delete a comma when deleting a field. |
Edit: Where clauses are a separate issue, see #38 What about structs with trait bounds? struct Peekable<I>
where I: Iterator,
I::Item: Debug, // This is only to illustrate more bounds
{
peek: Option<I::Item>,
iter: I,
}
|
I'm not a fan of visual identing, and it seems like the tone in other issues is against it. I'd rather have: struct Peekable<I> where // 'where' on the same line, following the example of '{'
I: Iterator, // one block indent, just like struct fields or any other list item
I::Item: Debug, // trailing comma, of course
{ // visually ends the 'where' items and begins the struct items
peek: Option<I::Item>,
iter: I,
} |
A hanging |
I'd like to also discuss where clauses separately, since they equally affect functions, traits etc., I created #38 for that. |
I think this is ready for FCP, summarised in #30 (comment). |
@nrc I would like to take a crack at this one. |
assigning to myself for mentoring and so we can see @johnthagen is working on it |
Closed by #53 |
I'd like to discuss generics separately (#29). I'd like to include unit and tuple structs here.
The text was updated successfully, but these errors were encountered: