parent_shape.block_indent(context.config.tab_spaces)),
false)
} else {
- (chain_indent_newline(context, shape.add_offset(parent_rewrite.len())), false)
+ (shape.block_indent(context.config.tab_spaces), false)
};
let max_width = try_opt!((shape.width + shape.indent.width() + shape.offset)
let mut shape = try_opt!(parent_shape.shrink_left(last_line_width(&parent_rewrite)));
match context.config.chain_indent {
BlockIndentStyle::Visual => other_child_shape,
- BlockIndentStyle::Inherit => shape,
BlockIndentStyle::Tabbed => {
shape.offset = shape.offset.checked_sub(context.config.tab_spaces).unwrap_or(0);
shape.indent.block_indent += context.config.tab_spaces;
.collect::<Option<Vec<_>>>());
// Total of all items excluding the last.
- let almost_total = rewrites[..rewrites.len() - 1]
- .iter()
- .fold(0, |a, b| a + first_line_width(b)) + parent_rewrite.len();
+ let almost_total = rewrites[..rewrites.len() - 1].iter().fold(0, |a, b| {
+ a + first_line_width(b)
+ }) + parent_rewrite.len();
let veto_single_line = if subexpr_list.len() > context.config.chain_one_line_max - 1 {
// -1 above because subexpr_list does not include the parent.
fn chain_indent(context: &RewriteContext, shape: Shape) -> Shape {
match context.config.chain_indent {
BlockIndentStyle::Visual => shape.visual_indent(0),
- BlockIndentStyle::Inherit => shape.block_indent(0),
BlockIndentStyle::Tabbed => shape.block_indent(context.config.tab_spaces),
}
}
-// 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, shape: Shape) -> Shape {
- match context.config.chain_indent {
- BlockIndentStyle::Inherit => shape.block_indent(0),
- BlockIndentStyle::Visual | BlockIndentStyle::Tabbed => {
- shape.block_indent(context.config.tab_spaces)
- }
- }
-}
-
fn rewrite_method_call_with_overflow(expr_kind: &ast::ExprKind,
last: &mut String,
almost_total: usize,
let (lo, type_str) = if types.is_empty() {
(args[0].span.hi, String::new())
} else {
- let type_list: Vec<_> = try_opt!(types.iter()
- .map(|ty| ty.rewrite(context, shape))
- .collect());
+ let type_list: Vec<_> =
+ try_opt!(types.iter().map(|ty| ty.rewrite(context, shape)).collect());
let type_str = if context.config.spaces_within_angle_brackets && type_list.len() > 0 {
format!("::< {} >", type_list.join(", "))
format!("::<{}>", type_list.join(", "))
};
- (types.last().unwrap().span.hi, type_str)
+ (types.last()
+ .unwrap()
+ .span
+ .hi,
+ type_str)
};
let callee_str = format!(".{}{}", method_name, type_str);