diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-02-17 20:38:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-17 20:38:00 +0100 |
| commit | 16481a285733f004ab9c5573c1e7fd5b602b3ddd (patch) | |
| tree | 9e71eb79ade91c6e7633b163b389450246a830fd /library/std/src/sys/unix/stack_overflow.rs | |
| parent | 13730e90bde2e55efa31b127e2175d5e90772044 (diff) | |
| parent | 15197cbc61450bd19328387ad9a04500e35d7086 (diff) | |
| download | rust-16481a285733f004ab9c5573c1e7fd5b602b3ddd.tar.gz rust-16481a285733f004ab9c5573c1e7fd5b602b3ddd.zip | |
Rollup merge of #82169 - not-an-aardvark:assert-lazy-format-expressions, r=sfackler
Document that `assert!` format arguments are evaluated lazily
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.
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
