File tree 2 files changed +35
-3
lines changed
2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,8 @@ between a unary operator and its operand.
284
284
285
285
### Binary operations
286
286
287
- Do include spaces around binary ops (i.e., ` x + 1 ` , not ` x+1 ` ) (including ` = ` ).
287
+ Do include spaces around binary ops (i.e., ` x + 1 ` , not ` x+1 ` ) (including ` = `
288
+ and other assignment operators such as ` += ` or ` *= ` ).
288
289
289
290
For comparison operators, because for ` T op U ` , ` &T op &U ` is also implemented:
290
291
if you have ` t: &T ` , and ` u: U ` , prefer ` *t op u ` to ` t op &u ` . In general,
@@ -301,6 +302,9 @@ foo + bar + baz
301
302
+ qux + whatever
302
303
```
303
304
305
+ Prefer line-breaking at an assignment operator (either ` = ` or ` += ` , etc.) rather
306
+ than at other binary operators.
307
+
304
308
### Control flow
305
309
306
310
Do not include extraneous parentheses for ` if ` and ` while ` expressions.
@@ -585,8 +589,8 @@ body on a new line:
585
589
```
586
590
587
591
If required to break the pattern, put each clause of the pattern on its own
588
- line, breaking before the ` | ` . If there is an ` if ` clause, then you must use the
589
- above form:
592
+ line with no additional indent , breaking before the ` | ` . If there is an ` if `
593
+ clause, then you must use the above form:
590
594
591
595
``` rust
592
596
a_very_long_pattern
Original file line number Diff line number Diff line change @@ -198,12 +198,40 @@ pub trait IndexRanges:
198
198
```
199
199
200
200
201
+ ### Impls
202
+
203
+ Impl items should be block indented. If there are no items, the impl may be
204
+ formatted on a single line. Otherwise there should be line-breaks after the
205
+ opening brace and before the closing brace:
206
+
207
+ ``` rust
208
+ impl Foo {}
209
+
210
+ impl Bar for Foo {
211
+ ...
212
+ }
213
+ ```
214
+
215
+ Avoid line-breaking in the signature if possible. If a line break is required in
216
+ a non-inherent impl, break immediately before ` for ` , block indent the concrete type
217
+ and put the opening brace on it's own line:
218
+
219
+ ``` rust
220
+ impl Bar
221
+ for Foo
222
+ {
223
+ ...
224
+ }
225
+ ```
226
+
227
+
201
228
### Extern crate
202
229
203
230
` extern crate foo; `
204
231
205
232
Use spaces around keywords, no spaces around the semi-colon.
206
233
234
+
207
235
### Modules
208
236
209
237
``` rust
You can’t perform that action at this time.
0 commit comments