Skip to content

Commit

Permalink
Function calls
Browse files Browse the repository at this point in the history
Closes #65
  • Loading branch information
nrc committed Feb 5, 2018
1 parent d0f5437 commit 145e5d4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Do not put a space between an argument, and the comma which follows.

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

Prefer not to break a line in the callee expression.

#### Single-line calls

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

#### Multi-line calls

If the function call is not *small*, it would otherwise over-run the max width,
or any argument or the callee is multi-line, then the call should be formatted
across multiple lines. In this case, each argument should be on it's own block-
indented line, there should be a newline after the opening parenthesis and
before the closing parenthesis, and there should be a trailing comma. E.g.,

```rust
a_function_call(
arg1,
a_nested_call(a, b),
)
```


### Method calls

Follow the function rules for calling.

#### Single-line

Do not put any spaces around the `.`.

```rust
x.foo().bar().baz(x, y, z);
```


### Casts (`as`)

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



### Match

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

0 comments on commit 145e5d4

Please sign in to comment.