]> git.lizzy.rs Git - rust.git/commitdiff
Format source code
authorSeiichi Uchida <topecongiro@localhost.localdomain>
Sat, 13 May 2017 12:08:10 +0000 (21:08 +0900)
committerSeiichi Uchida <topecongiro@localhost.localdomain>
Sat, 13 May 2017 12:08:10 +0000 (21:08 +0900)
src/comment.rs

index 9df303c86b246b8b05e5f2d5bfb7c54f01bba595..17b1700accddd8c6e96530247a11ad09e4cffbf6 100644 (file)
@@ -52,37 +52,35 @@ pub fn rewrite_comment(orig: &str,
         return light_rewrite_comment(orig, shape.indent, config);
     }
 
-    let (opener, closer, line_start) =
-        if block_style {
+    let (opener, closer, line_start) = if block_style {
+        ("/* ", " */", " * ")
+    } else if !config.normalize_comments {
+        if orig.starts_with("/**") && !orig.starts_with("/**/") {
+            ("/** ", " **/", " ** ")
+        } else if orig.starts_with("/*!") {
+            ("/*! ", " */", " * ")
+        } else if orig.starts_with("/*") {
             ("/* ", " */", " * ")
-        } else if !config.normalize_comments {
-            if orig.starts_with("/**") && !orig.starts_with("/**/") {
-                ("/** ", " **/", " ** ")
-            } else if orig.starts_with("/*!") {
-                ("/*! ", " */", " * ")
-            } else if orig.starts_with("/*") {
-                ("/* ", " */", " * ")
-            } else if orig.starts_with("///") {
-                ("/// ", "", "/// ")
-            } else if orig.starts_with("//!") {
-                ("//! ", "", "//! ")
-            } else {
-                ("// ", "", "// ")
-            }
-        } else if orig.starts_with("///") ||
-                  (orig.starts_with("/**") && !orig.starts_with("/**/")) {
+        } else if orig.starts_with("///") {
             ("/// ", "", "/// ")
-        } else if orig.starts_with("//!") || orig.starts_with("/*!") {
+        } else if orig.starts_with("//!") {
             ("//! ", "", "//! ")
-        } else if is_custom_comment(orig) {
-            if orig.chars().nth(3) == Some(' ') {
-                (&orig[0..4], "", &orig[0..4])
-            } else {
-                (&orig[0..3], "", &orig[0..3])
-            }
         } else {
             ("// ", "", "// ")
-        };
+        }
+    } else if orig.starts_with("///") || (orig.starts_with("/**") && !orig.starts_with("/**/")) {
+        ("/// ", "", "/// ")
+    } else if orig.starts_with("//!") || orig.starts_with("/*!") {
+        ("//! ", "", "//! ")
+    } else if is_custom_comment(orig) {
+        if orig.chars().nth(3) == Some(' ') {
+            (&orig[0..4], "", &orig[0..4])
+        } else {
+            (&orig[0..3], "", &orig[0..3])
+        }
+    } else {
+        ("// ", "", "// ")
+    };
 
     let max_chars = shape
         .width