Skip to content

Commit

Permalink
Binary ops
Browse files Browse the repository at this point in the history
Closes #18
  • Loading branch information
nrc committed Feb 5, 2018
1 parent 1850f2a commit 3806502
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ fn main() {
### Unary operations

Do not include a space between a unary op and its operand (i.e., `!x`, not
`! x`).
`! x`). However, there must be a space after `&mut`. Avoid line-breaking
between a unary operator and its operand.

### Binary operations

Expand All @@ -203,6 +204,17 @@ For comparison operators, because for `T op U`, `&T op &U` is also implemented:
if you have `t: &T`, and `u: U`, prefer `*t op u` to `t op &u`. In general,
within expressions, prefer dereferencing to taking references.

Use parentheses liberally, do not necessarily elide them due to precedence.
Tools should not automatically insert or remove parentheses. Do not use spaces
to indicate precedence.

If line-breaking, put the operator on a new line and block indent. E.g.,

```rust
foo + bar + baz
+ qux + whatever
```

### Control flow

Do not include extraneous parentheses for `if` and `while` expressions.
Expand Down

0 comments on commit 3806502

Please sign in to comment.