diff options
| author | Nick Cameron <nrc@ncameron.org> | 2015-09-27 10:50:50 +1300 |
|---|---|---|
| committer | Nick Cameron <nrc@ncameron.org> | 2015-09-27 10:50:50 +1300 |
| commit | dad46265170d76ab2800b43c6bfd44dfbc4d2b6d (patch) | |
| tree | 040e0cc2499526e1cfdbb52c0cbdb6a9d227448b /src/expr.rs | |
| parent | fd057ab59559449e9112925540e09fd6b75d676f (diff) | |
| parent | e4c15b4e1ccdf7739bb3b6b855533036ea110e9d (diff) | |
Merge pull request #368 from nrc/struct-wide
Use a width heuristic for struct lits
Diffstat (limited to 'src/expr.rs')
| -rw-r--r-- | src/expr.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/expr.rs b/src/expr.rs index 79e03e644e4..f2e6b1e0dfa 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1226,11 +1226,15 @@ fn rewrite_struct_lit<'a>(context: &RewriteContext, span_after(span, "{", context.codemap), span.hi); - let tactic = match (context.config.struct_lit_style, fields.len()) { + let mut tactic = match (context.config.struct_lit_style, fields.len()) { (StructLitStyle::Visual, 1) => ListTactic::HorizontalVertical, _ => context.config.struct_lit_multiline_style.to_list_tactic(), }; + if tactic == ListTactic::HorizontalVertical && fields.len() > 1 { + tactic = ListTactic::LimitedHorizontalVertical(context.config.struct_lit_width); + } + let fmt = ListFormatting { tactic: tactic, separator: ",", |
