Skip to content

Commit 02ee9a6

Browse files
committed
Fix some things in the operator section
1 parent 7cc613d commit 02ee9a6

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/expressions.md

+7-15
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,11 @@ assert_eq!(*y, 11);
772772

773773
### The `?` operator.
774774

775-
The `?` operator can be applied to values of the `Result<T, E>` type to
776-
propagate errors. If applied to `Err(e)` it will return `Err(From::from(e))`
777-
from the enclosing function or closure. If applied to `Ok(x)` it will unwrap
778-
the value to return `x`. Unlike other unary operators `?` is written in postfix
779-
notation. `?` cannot be overloaded.
775+
The `?` ("question mark") operator can be applied to values of the `Result<T,
776+
E>` type to propagate errors. If applied to `Err(e)` it will return
777+
`Err(From::from(e))` from the enclosing function or closure. If applied to
778+
`Ok(x)` it will unwrap the value to return `x`. Unlike other unary operators
779+
`?` is written in postfix notation. `?` cannot be overloaded.
780780

781781
```rust
782782
# use std::num::ParseIntError;
@@ -871,7 +871,7 @@ functions and macros in the standard library can then use that assumption
871871
above, these operators implicitly take shared borrows of their operands,
872872
evaluating them in lvalue context:
873873

874-
```rust
874+
```rust,ignore
875875
a == b;
876876
// is equivalent to
877877
::std::cmp::PartialEq::eq(&a, &b);
@@ -1018,21 +1018,15 @@ x += 4;
10181018
assert_eq!(x, 14);
10191019
```
10201020

1021-
10221021
### Operator precedence
10231022

10241023
The precedence of Rust operators is ordered as follows, going from strong to
10251024
weak. Binary Operators at the same precedence level are evaluated in the order
1026-
given by their associativity.#
1025+
given by their associativity.
10271026

1028-
<!-- The non-operator things are more a matter of how things are parsed,
1029-
rather than are evaluated, so probably shouldn't be here. -->
10301027

10311028
| Operator | Associativity |
10321029
|-----------------------------|---------------------|
1033-
| paths | |
1034-
| block expressions <br> control flow block expressions <br> tuple expressions <br> array expressions <br> (braced) struct and variant expressions <br> method calls <br> field expressions | left to right |
1035-
| function calls <br> tuple struct expressions <br> index expressions | |
10361030
| `?` | |
10371031
| Unary `-` `*` `!` `&` `&mut` | |
10381032
| `as` `:` | left to right |
@@ -1048,8 +1042,6 @@ rather than are evaluated, so probably shouldn't be here. -->
10481042
| `..` `...` | Require parentheses |
10491043
| `<-` | right to left |
10501044
| `=` `+=` `-=` `*=` `/=` `%=` `&=` <code>&#124;=</code> `^=` `<<=` `>>=` | right to left |
1051-
| `return` `break` `continue`<br>Closure expressions | right to left |
1052-
10531045

10541046
## Grouped expressions
10551047

0 commit comments

Comments
 (0)