about summary refs log tree commit diff
path: root/src/items.rs
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2017-06-06 03:11:17 +0200
committerest31 <MTest31@outlook.com>2017-06-06 03:50:58 +0200
commitaa4cd311bb07ea25d89096e8fdd5d64b73666c28 (patch)
tree8eda35fc415720f1954538e6843e46a56e653f59 /src/items.rs
parentd04ab9e5ba46b21a49027ce38dc913b4617125ba (diff)
Add config options for spaces around the colon in struct literal fields
In Rust, colons are used for three purposes:

* Type annotations, including type ascription
* Trait bounds
* Struct literal fields

This commit adds options for the last missing of the three purposes,
struct literal fields.
Diffstat (limited to 'src/items.rs')
-rw-r--r--src/items.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/items.rs b/src/items.rs
index fdcf96454c7..bf7933b547c 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -14,10 +14,10 @@ use {Indent, Shape};
 use codemap::SpanUtils;
 use utils::{format_mutability, format_visibility, contains_skip, end_typaram, wrap_str,
             last_line_width, format_unsafety, trim_newlines, stmt_expr, semicolon_for_expr,
-            trimmed_last_line_width};
+            trimmed_last_line_width, colon_spaces};
 use lists::{write_list, itemize_list, ListItem, ListFormatting, SeparatorTactic, list_helper,
             DefinitiveListTactic, ListTactic, definitive_tactic, format_item_list};
-use expr::{is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, type_annotation_separator};
+use expr::{is_empty_block, is_simple_block_stmt, rewrite_assign_rhs};
 use comment::{FindUncommented, contains_comment, rewrite_comment, recover_comment_removed};
 use visitor::FmtVisitor;
 use rewrite::{Rewrite, RewriteContext};
@@ -27,6 +27,12 @@ use syntax::{ast, abi, codemap, ptr, symbol};
 use syntax::codemap::{Span, BytePos, mk_sp};
 use syntax::ast::ImplItem;
 
+fn type_annotation_separator(config: &Config) -> &str {
+    colon_spaces(config.space_before_type_annotation(),
+                 config.space_after_type_annotation_colon())
+}
+
+
 // Statements of the form
 // let pat: ty = init;
 impl Rewrite for ast::Local {