span_lo = qself.ty.span.hi + BytePos(1);
}
- let extra_offset = extra_offset(&result, shape);
- let shape = try_opt!(shape.shrink_left(extra_offset));
rewrite_path_segments(path_context,
result,
path.segments.iter().skip(skip_count),
SegmentParam::LifeTime(lt) => lt.rewrite(context, shape),
SegmentParam::Type(ty) => ty.rewrite(context, shape),
SegmentParam::Binding(binding) => {
- let mut result = format!("{} = ", binding.ident);
+ let mut result = match context.config.type_punctuation_density {
+ TypeDensity::Wide => format!("{} = ", binding.ident),
+ TypeDensity::Compressed => format!("{}=", binding.ident),
+ };
let budget = try_opt!(shape.width.checked_sub(result.len()));
- let rewrite =
- try_opt!(binding.ty
- .rewrite(context,
- Shape::legacy(budget, shape.indent + result.len())));
+ let rewrite = try_opt!(binding.ty.rewrite(context,
+ Shape::legacy(budget,
+ shape.indent +
+ result.len())));
result.push_str(&rewrite);
Some(result)
}
.chain(data.bindings.iter().map(|x| SegmentParam::Binding(&*x)))
.collect::<Vec<_>>();
- let next_span_lo = param_list.last().unwrap().get_span().hi + BytePos(1);
+ let next_span_lo = param_list.last()
+ .unwrap()
+ .get_span()
+ .hi + BytePos(1);
let list_lo = context.codemap.span_after(codemap::mk_sp(*span_lo, span_hi), "<");
let separator = if path_context == PathContext::Expr {
"::"
if bounds.len() == 0 {
Some(result)
} else {
- let appendix: Vec<_> = try_opt!(bounds.into_iter()
- .map(|b| b.rewrite(context, shape))
- .collect());
+ let appendix: Vec<_> =
+ try_opt!(bounds.into_iter().map(|b| b.rewrite(context, shape)).collect());
let colon = type_bound_colon(context);
let result = format!("{}{}{}", result, colon, appendix.join(" + "));
wrap_str(result, context.config.max_width, shape)
TypeDensity::Compressed => "+",
TypeDensity::Wide => " + ",
};
- let strs: Vec<_> = try_opt!(self.iter()
- .map(|b| b.rewrite(context, shape))
- .collect());
+ let strs: Vec<_> = try_opt!(self.iter().map(|b| b.rewrite(context, shape)).collect());
wrap_str(strs.join(joiner), context.config.max_width, shape)
}
}
// 6 is "for<> ".len()
let extra_offset = lifetime_str.len() + 6;
let max_path_width = try_opt!(shape.width.checked_sub(extra_offset));
- let path_str = try_opt!(self.trait_ref
- .rewrite(context,
- Shape::legacy(max_path_width,
- shape.indent + extra_offset)));
+ let path_str = try_opt!(self.trait_ref.rewrite(context,
+ Shape::legacy(max_path_width,
+ shape.indent +
+ extra_offset)));
Some(if context.config.spaces_within_angle_brackets && lifetime_str.len() > 0 {
format!("for< {} > {}", lifetime_str, path_str)
format!("&{} {}{}",
lt_str,
mut_str,
- try_opt!(mt.ty
- .rewrite(context,
- Shape::legacy(budget,
- shape.indent + 2 + mut_len +
- lt_len))))
+ try_opt!(mt.ty.rewrite(context,
+ Shape::legacy(budget,
+ shape.indent + 2 + mut_len +
+ lt_len))))
}
None => {
let budget = try_opt!(shape.width.checked_sub(1 + mut_len));
result.push_str(&try_opt!(bare_fn.lifetimes
.iter()
.map(|l| {
- l.rewrite(context,
+ l.rewrite(context,
Shape::legacy(try_opt!(shape.width.checked_sub(6)), shape.indent + 4))
- })
+ })
.intersperse(Some(", ".to_string()))
.collect::<Option<String>>()));
result.push_str("> ");