]> git.lizzy.rs Git - rust.git/commitdiff
Collapse if-else
authortopecongiro <seuchida@gmail.com>
Sun, 5 Nov 2017 05:03:30 +0000 (14:03 +0900)
committertopecongiro <seuchida@gmail.com>
Mon, 6 Nov 2017 04:52:25 +0000 (13:52 +0900)
src/comment.rs
src/items.rs

index 713ef4922d9ace02c2a80f2f40a71a8e4c6b54ea..6d5f48fbb2618973873ad463639e6db3e3e7ed9b 100644 (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) {
index 13450ea0f45e1a8b3d80247ce0369998fd36de89..37a1b1ca40b7f64797699e81b89312fe6befae52 100644 (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;