about summary refs log tree commit diff
path: root/src/chains.rs
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2016-04-22 19:26:42 +1200
committerNick Cameron <ncameron@mozilla.com>2016-04-22 19:26:42 +1200
commit19fa5c9ebb85aa7643d5917c406f6bcc0dc0ff52 (patch)
tree7ae2c73320bf3d4eb182d28882b88c41db7e9d35 /src/chains.rs
parent95cc135bacb3130402d2f1bbc69c9788ca791841 (diff)
Update docs (and a function name)
Diffstat (limited to 'src/chains.rs')
-rw-r--r--src/chains.rs33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/chains.rs b/src/chains.rs
index 255db49386c..d4faedca5c1 100644
--- a/src/chains.rs
+++ b/src/chains.rs
@@ -54,35 +54,26 @@
 ///     .baz();
 /// ```
 ///
-/// `chain_indent` dictates how the rest of the chain is aligned. This only seems
-/// to have an effect if the first non-root part of the chain is put on a
-/// newline, otherwise we align the dots:
-/// ```
-/// foo.bar
-///    .baz()
-/// ```
+/// `chain_indent` dictates how the rest of the chain is aligned.
 /// If the first item in the chain is a block expression, we align the dots with
 /// the braces.
-///
-/// Otherwise:
 /// Visual:
 /// ```
-/// let a = foo(aaa, bbb)
-///             .bar
-///             .baz()
+/// let a = foo.bar
+///            .baz()
+///            .qux
 /// ```
-/// Visual seems to be a tab indented from the indent of the whole expression.
 /// Inherit:
 /// ```
-/// let a = foo(aaa, bbb)
-/// .bar
+/// let a = foo.bar
 /// .baz()
+/// .qux
 /// ```
 /// Tabbed:
 /// ```
-/// let a = foo(aaa, bbb)
-///     .bar
+/// let a = foo.bar
 ///     .baz()
+///     .qux
 /// ```
 /// `chains_overflow_last` applies only to chains where the last item is a
 /// method call. Usually, any line break in a chain sub-expression causes the
@@ -127,7 +118,7 @@ pub fn rewrite_chain(expr: &ast::Expr,
     } else if parent_rewrite.contains('\n') {
         (chain_indent(context, parent_block_indent.block_indent(context.config)), false)
     } else {
-        (hacked_chain_indent(context, offset + Indent::new(0, parent_rewrite.len())), false)
+        (chain_indent_newline(context, offset + Indent::new(0, parent_rewrite.len())), false)
     };
 
     let max_width = try_opt!((width + offset.width()).checked_sub(indent.width()));
@@ -259,9 +250,9 @@ fn chain_indent(context: &RewriteContext, offset: Indent) -> Indent {
     }
 }
 
-// Temporary hack - ignores visual indenting because this function should be
-// called where it is not possible to use visual indentation.
-fn hacked_chain_indent(context: &RewriteContext, _offset: Indent) -> Indent {
+// Ignores visual indenting because this function should be called where it is
+// not possible to use visual indentation because we are starting on a newline.
+fn chain_indent_newline(context: &RewriteContext, _offset: Indent) -> Indent {
     match context.config.chain_indent {
         BlockIndentStyle::Inherit => context.block_indent,
         BlockIndentStyle::Visual | BlockIndentStyle::Tabbed => {