@@ -22,10 +22,6 @@ typically by using a formatting tool's default settings.
22
22
23
23
## Formatting conventions
24
24
25
- These formatting conventions are a work in progress, and may do anything they
26
- like, up to and including eating your laundry.
27
-
28
-
29
25
### Indentation and line width
30
26
31
27
Use spaces, not tabs. Each level of indentation must be four spaces. The maximum
@@ -157,6 +153,35 @@ combining multiple `derive` attributes into a single attribute, the ordering of
157
153
the derived names should be preserved. E.g., `#[ derive(bar)] #[ derive(foo)]
158
154
struct Baz;` should be formatted to ` #[ derive(bar, foo)] struct Baz;`.
159
155
156
+ ### * small* items
157
+
158
+ In many places in this guide we specify that a formatter may format an item
159
+ differently if it is * small* , for example struct literals:
160
+
161
+ ``` rust
162
+ // Normal formatting
163
+ Foo {
164
+ f1 : an_expression ,
165
+ f2 : another_expression (),
166
+ }
167
+
168
+ // *small* formatting
169
+ Foo { f1 , f2 }
170
+ ```
171
+
172
+ We leave it to individual tools to decide on exactly what * small* means. In
173
+ particular, tools are free to use different definitions in different
174
+ circumstances.
175
+
176
+ Some suitable heuristics are the size of the item (in characters) or the
177
+ complexity of an item (for example, that all components must be simple names,
178
+ not more complex sub-expressions). For more discussion on suitable heuristics,
179
+ see the discussion on [ this issue] ( https://github.com/rust-lang-nursery/fmt-rfcs/issues/47 ) .
180
+
181
+ Tools should give the user an option to ignore such heuristics and always use
182
+ the normal formatting.
183
+
184
+
160
185
## [ Non-formatting conventions] ( advice.md )
161
186
162
187
## [ Cargo.toml conventions] ( cargo.md )
0 commit comments