Collapse if-else

This commit is contained in:
topecongiro 2017-11-05 14:03:30 +09:00
parent b023cc831c
commit 4e1a75a429
2 changed files with 7 additions and 9 deletions

View File

@ -327,12 +327,10 @@ fn rewrite_comment_inner(
if line.is_empty() {
continue;
}
} else if is_prev_line_multi_line && !line.is_empty() {
result.push(' ')
} else {
if is_prev_line_multi_line && !line.is_empty() {
result.push(' ')
} else {
result.push_str(&comment_line_separator);
}
result.push_str(&comment_line_separator);
}
if config.wrap_comments() && line.len() > fmt.shape.width && !has_url(line) {

View File

@ -313,10 +313,10 @@ pub fn rewrite_fn(
let (mut result, force_newline_brace) =
rewrite_fn_base(&context, indent, ident, fn_sig, span, newline_brace, true)?;
if self.config.fn_brace_style() == BraceStyle::AlwaysNextLine || force_newline_brace {
newline_brace = true;
} else if last_line_width(&result) + 2 > self.shape().width {
// 2 = ` {`
// 2 = ` {`
if self.config.fn_brace_style() == BraceStyle::AlwaysNextLine || force_newline_brace
|| last_line_width(&result) + 2 > self.shape().width
{
newline_brace = true;
} else if !result.contains('\n') {
newline_brace = false;