@@ -772,11 +772,11 @@ assert_eq!(*y, 11);
772
772
773
773
### The ` ? ` operator.
774
774
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.
780
780
781
781
``` rust
782
782
# use std :: num :: ParseIntError ;
@@ -871,7 +871,7 @@ functions and macros in the standard library can then use that assumption
871
871
above, these operators implicitly take shared borrows of their operands,
872
872
evaluating them in lvalue context:
873
873
874
- ``` rust
874
+ ``` rust,ignore
875
875
a == b;
876
876
// is equivalent to
877
877
::std::cmp::PartialEq::eq(&a, &b);
@@ -1018,21 +1018,15 @@ x += 4;
1018
1018
assert_eq! (x , 14 );
1019
1019
```
1020
1020
1021
-
1022
1021
### Operator precedence
1023
1022
1024
1023
The precedence of Rust operators is ordered as follows, going from strong to
1025
1024
weak. Binary Operators at the same precedence level are evaluated in the order
1026
- given by their associativity.#
1025
+ given by their associativity.
1027
1026
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. -->
1030
1027
1031
1028
| Operator | Associativity |
1032
1029
| -----------------------------| ---------------------|
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 | |
1036
1030
| ` ? ` | |
1037
1031
| Unary ` - ` ` * ` ` ! ` ` & ` ` &mut ` | |
1038
1032
| ` as ` ` : ` | left to right |
@@ -1048,8 +1042,6 @@ rather than are evaluated, so probably shouldn't be here. -->
1048
1042
| ` .. ` ` ... ` | Require parentheses |
1049
1043
| ` <- ` | right to left |
1050
1044
| ` = ` ` += ` ` -= ` ` *= ` ` /= ` ` %= ` ` &= ` <code >| ; =</code > ` ^= ` ` <<= ` ` >>= ` | right to left |
1051
- | ` return ` ` break ` ` continue ` <br >Closure expressions | right to left |
1052
-
1053
1045
1054
1046
## Grouped expressions
1055
1047
0 commit comments