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.
This commit is contained in:
est31 2017-06-06 03:11:17 +02:00
parent d04ab9e5ba
commit aa4cd311bb
14 changed files with 121 additions and 9 deletions

View file

@ -0,0 +1,6 @@
// rustfmt-space_after_struct_lit_field_colon: false
const LOREM: Lorem = Lorem {
ipsum:dolor,
sit : amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_after_struct_lit_field_colon: true
const LOREM: Lorem = Lorem {
ipsum:dolor,
sit : amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_before_struct_lit_field_colon: false
const LOREM: Lorem = Lorem {
ipsum:dolor,
sit : amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_before_struct_lit_field_colon: true
const LOREM: Lorem = Lorem {
ipsum:dolor,
sit : amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_after_struct_lit_field_colon: false
const LOREM: Lorem = Lorem {
ipsum:dolor,
sit:amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_after_struct_lit_field_colon: true
const LOREM: Lorem = Lorem {
ipsum: dolor,
sit: amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_before_struct_lit_field_colon: false
const LOREM: Lorem = Lorem {
ipsum: dolor,
sit: amet,
};

View file

@ -0,0 +1,6 @@
// rustfmt-space_before_struct_lit_field_colon: true
const LOREM: Lorem = Lorem {
ipsum : dolor,
sit : amet,
};

View file

@ -9,5 +9,5 @@ struct S {
fieldVar : i32,
}
fn f() {
S { fieldVar : 42 }
S { fieldVar: 42 }
}

View file

@ -10,5 +10,5 @@ struct S {
fieldVar :i32,
}
fn f() {
S { fieldVar :42 }
S { fieldVar: 42 }
}