Skip to content

Commit 145e5d4

Browse files
committed
Function calls
Closes #65
1 parent d0f5437 commit 145e5d4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

guide/expressions.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ Do not put a space between an argument, and the comma which follows.
328328

329329
Do put a space between an argument, and the comma which precedes it.
330330

331+
Prefer not to break a line in the callee expression.
332+
331333
#### Single-line calls
332334

333335
Do not put a space between the function name and open paren, between the open
@@ -339,18 +341,33 @@ Do not put a comma after the last argument.
339341
foo(x, y, z)
340342
```
341343

344+
#### Multi-line calls
345+
346+
If the function call is not *small*, it would otherwise over-run the max width,
347+
or any argument or the callee is multi-line, then the call should be formatted
348+
across multiple lines. In this case, each argument should be on it's own block-
349+
indented line, there should be a newline after the opening parenthesis and
350+
before the closing parenthesis, and there should be a trailing comma. E.g.,
351+
352+
```rust
353+
a_function_call(
354+
arg1,
355+
a_nested_call(a, b),
356+
)
357+
```
358+
359+
342360
### Method calls
343361

344362
Follow the function rules for calling.
345363

346-
#### Single-line
347-
348364
Do not put any spaces around the `.`.
349365

350366
```rust
351367
x.foo().bar().baz(x, y, z);
352368
```
353369

370+
354371
### Casts (`as`)
355372

356373
Put spaces before and after `as`:
@@ -360,6 +377,7 @@ let cstr = "Hi\0" as *const str as *const [u8] as *const std::os::raw::c_char;
360377
```
361378

362379

380+
363381
### Match
364382

365383
Prefer not to line-break inside the discriminant expression. There must always

0 commit comments

Comments
 (0)