-
Notifications
You must be signed in to change notification settings - Fork 933
leave the comment in parentheses of argumentless Fn #3518
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
Conversation
I didn't implement the logic for the below case.
Because rustfmt can format and leave the comment for below code.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rchaser53 for the fix
src/types.rs
Outdated
&Vec::<ListItem>::new(), | ||
ListTactic::HorizontalVertical, | ||
Separator::Comma, | ||
shape.width.saturating_sub(2 + output.len()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does 2
represent ? Can you add a comment that describes its meaning ?
I've seen the following format: for example // 1 = "{"
which means the digit 1 is about the opening curly bracket.
src/types.rs
Outdated
shape.width.saturating_sub(2 + output.len()), | ||
) | ||
}; | ||
let list_hi = context.snippet_provider.span_after_last(span, ")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can add a new method in source_map::SpanUtils
called span_before_last
, this way the following could be simplified and avoid the BytePos(1)
substraction.
- create span_before_last - create get_tactics and add comment
Thank you the review. I changed my source. |
Thanks. I fixed about indents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for nitpicking and requesting changes multiple times, though with those fixed I think this is ready to merge!
src/types.rs
Outdated
@@ -381,6 +392,22 @@ fn type_bound_colon(context: &RewriteContext<'_>) -> &'static str { | |||
colon_spaces(context.config) | |||
} | |||
|
|||
// If the return type is multi-lined, then force to use multiple lines for | |||
// arguments as well. | |||
fn get_tactics(item_vec: &Vec<ListItem>, output: &str, shape: &Shape) -> DefinitiveListTactic { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use &[_]
over &Vec<_>
. Also Shape
implements Copy
so we need not take a reference:
fn get_tactics(item_vec: &Vec<ListItem>, output: &str, shape: &Shape) -> DefinitiveListTactic { | |
fn get_tactics(item_vec: &[ListItem], output: &str, shape: Shape) -> DefinitiveListTactic { |
src/types.rs
Outdated
DefinitiveListTactic::Vertical | ||
} else { | ||
definitive_tactic( | ||
&*item_vec, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified with the above change:
&*item_vec, | |
item_vec, |
I improved it. |
Thank you! |
related: #3508