]> git.lizzy.rs Git - rust.git/blobdiff - src/items.rs
Format source codes
[rust.git] / src / items.rs
index 6285811e79e28e6b2dfd0ad592503e508ec9bb8b..867051baea01dc6ed389d882b71b5f7eb44423d1 100644 (file)
@@ -550,12 +550,14 @@ fn format_variant(&self, field: &ast::Variant, one_line_width: usize) -> Option<
                 self.block_indent,
                 Some(one_line_width),
             )?,
-            ast::VariantData::Unit(..) => if let Some(ref expr) = field.node.disr_expr {
-                let lhs = format!("{} =", field.node.name);
-                rewrite_assign_rhs(&context, lhs, &**expr, shape)?
-            } else {
-                field.node.name.to_string()
-            },
+            ast::VariantData::Unit(..) => {
+                if let Some(ref expr) = field.node.disr_expr {
+                    let lhs = format!("{} =", field.node.name);
+                    rewrite_assign_rhs(&context, lhs, &**expr, shape)?
+                } else {
+                    field.node.name.to_string()
+                }
+            }
         };
 
         let attrs_extendable = attrs_str.is_empty()
@@ -643,11 +645,13 @@ pub fn format_impl(
             _ if last_line_contains_single_line_comment(&result) => result.push_str(&sep),
             BraceStyle::AlwaysNextLine => result.push_str(&sep),
             BraceStyle::PreferSameLine => result.push(' '),
-            BraceStyle::SameLineWhere => if !where_clause_str.is_empty() {
-                result.push_str(&sep);
-            } else {
-                result.push(' ');
-            },
+            BraceStyle::SameLineWhere => {
+                if !where_clause_str.is_empty() {
+                    result.push_str(&sep);
+                } else {
+                    result.push(' ');
+                }
+            }
         }
 
         result.push('{');
@@ -1039,14 +1043,16 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
                 result.push_str(&offset.to_string(context.config));
             }
             BraceStyle::PreferSameLine => result.push(' '),
-            BraceStyle::SameLineWhere => if !where_clause_str.is_empty()
-                && (!trait_items.is_empty() || result.contains('\n'))
-            {
-                result.push('\n');
-                result.push_str(&offset.to_string(context.config));
-            } else {
-                result.push(' ');
-            },
+            BraceStyle::SameLineWhere => {
+                if !where_clause_str.is_empty()
+                    && (!trait_items.is_empty() || result.contains('\n'))
+                {
+                    result.push('\n');
+                    result.push_str(&offset.to_string(context.config));
+                } else {
+                    result.push(' ');
+                }
+            }
         }
         result.push('{');