Commit 7676f13
committed
Document that
It can be useful to do some computation in `assert!` format arguments, in order to get better error messages. For example:
```rust
assert!(
some_condition,
"The state is invalid. Details: {}",
expensive_call_to_get_debugging_info(),
);
```
It seems like `assert!` only evaluates the format arguments if the assertion fails, which is useful but doesn't appear to be documented anywhere. This PR documents the behavior and adds some tests.assert! format arguments are evaluated lazily1 parent 6f82698 commit 7676f13
1 file changed
+2
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1208 | 1208 | | |
1209 | 1209 | | |
1210 | 1210 | | |
1211 | | - | |
| 1211 | + | |
| 1212 | + | |
1212 | 1213 | | |
1213 | 1214 | | |
1214 | 1215 | | |
| |||
0 commit comments