Commit b186cd7
committed
improve panic message on
This is something that has been bothering me for years,
which (naively) seems simple to fix.
The message passed to `.expect(msg)` is printed in
(at least potentially) confusing tway to the user:
```
let x: Option<u32> = None;
x.expect("valid x value");
// thread 'main' panicked at ...:
// valid x value
```
IMO, it would be much better if it got reported as:
```
// thread 'main' panicked at ...:
// expected: valid x value
```
Then, no matter how the message is formulated, it
should be clear that it was the *expectation*, not
the failing condition itself.expect
1 parent 2c12b4a commit b186cd7
2 files changed
+15
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
955 | 955 | | |
956 | 956 | | |
957 | 957 | | |
958 | | - | |
| 958 | + | |
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
| |||
1783 | 1783 | | |
1784 | 1784 | | |
1785 | 1785 | | |
1786 | | - | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
1787 | 1791 | | |
1788 | 1792 | | |
1789 | 1793 | | |
| |||
2045 | 2049 | | |
2046 | 2050 | | |
2047 | 2051 | | |
2048 | | - | |
2049 | | - | |
| 2052 | + | |
| 2053 | + | |
2050 | 2054 | | |
2051 | 2055 | | |
2052 | 2056 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
1089 | | - | |
| 1089 | + | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | 1092 | | |
| |||
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
1137 | | - | |
| 1137 | + | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
| |||
1197 | 1197 | | |
1198 | 1198 | | |
1199 | 1199 | | |
1200 | | - | |
| 1200 | + | |
1201 | 1201 | | |
1202 | 1202 | | |
1203 | 1203 | | |
| |||
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
1231 | | - | |
| 1231 | + | |
1232 | 1232 | | |
1233 | 1233 | | |
1234 | 1234 | | |
| |||
1728 | 1728 | | |
1729 | 1729 | | |
1730 | 1730 | | |
1731 | | - | |
1732 | | - | |
| 1731 | + | |
| 1732 | + | |
1733 | 1733 | | |
1734 | 1734 | | |
1735 | 1735 | | |
| |||
1740 | 1740 | | |
1741 | 1741 | | |
1742 | 1742 | | |
1743 | | - | |
| 1743 | + | |
1744 | 1744 | | |
1745 | 1745 | | |
1746 | 1746 | | |
| |||
0 commit comments