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() { if line.is_empty() {
continue; continue;
} }
} else if is_prev_line_multi_line && !line.is_empty() {
result.push(' ')
} else { } else {
if is_prev_line_multi_line && !line.is_empty() { result.push_str(&comment_line_separator);
result.push(' ')
} else {
result.push_str(&comment_line_separator);
}
} }
if config.wrap_comments() && line.len() > fmt.shape.width && !has_url(line) { if config.wrap_comments() && line.len() > fmt.shape.width && !has_url(line) {

View File

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