diff options
| author | Markus Westerlind <marwes91@gmail.com> | 2015-11-28 13:59:14 +0100 |
|---|---|---|
| committer | Markus Westerlind <marwes91@gmail.com> | 2015-11-28 13:59:14 +0100 |
| commit | 052fddd4ddd64d3b1a54aa50cb57e95b7d6cbdcc (patch) | |
| tree | 71095cdc2c719fd05c0d7729f4dd5114f79790a3 | |
| parent | 937467c35820031f3803962675b3a5304d0f5c48 (diff) | |
Use the BraceStyle config to calculate the width for braces in where clasues
| -rw-r--r-- | src/items.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/items.rs b/src/items.rs index f1be0ed76a1..a3eb7f7a4c9 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1471,12 +1471,16 @@ fn rewrite_where_clause(context: &RewriteContext, }; let preds_str = try_opt!(write_list(&item_vec, &fmt)); - // When '{' is the terminator just assume that it is put on the next line for single line where - // clauses - let end_length = if terminator == ";" { - 1 + let end_length = if terminator == "{" { + // If the brace is on the next line we don't need to count it otherwise it needs two + // characters " {" + match context.config.item_brace_style { + BraceStyle::AlwaysNextLine => 0, + BraceStyle::PreferSameLine => 2, + BraceStyle::SameLineWhere => 0, + } } else { - 0 + terminator.len() }; if density == Density::Tall || preds_str.contains('\n') || indent.width() + " where ".len() + preds_str.len() + end_length > width { |
