-
- let colon = type_bound_colon(context);
-
- if !bound_lifetimes.is_empty() {
- let lifetime_str: String = bound_lifetimes
- .iter()
- .map(|lt| lt.rewrite(context, shape))
- .collect::<Option<Vec<_>>>()?
- .join(", ");
-
- // 6 = "for<> ".len()
- let used_width = lifetime_str.len() + type_str.len() + colon.len() + 6;
- let ty_shape = shape.offset_left(used_width)?;
- let bounds = bounds
- .iter()
- .map(|ty_bound| ty_bound.rewrite(context, ty_shape))
- .collect::<Option<Vec<_>>>()?;
- let bounds_str = join_bounds(context, ty_shape, &bounds);
-
- if context.config.spaces_within_parens_and_brackets()
- && !lifetime_str.is_empty()
- {
- format!(
- "for< {} > {}{}{}",
- lifetime_str, type_str, colon, bounds_str
- )
- } else {
- format!("for<{}> {}{}{}", lifetime_str, type_str, colon, bounds_str)
- }
+ let colon = type_bound_colon(context).trim_right();
+ let lhs = if let Some(lifetime_str) =
+ rewrite_lifetime_param(context, shape, bound_generic_params)
+ {
+ format!("for<{}> {}{}", lifetime_str, type_str, colon)