Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that assert! format arguments are evaluated lazily #82169

Merged
merged 2 commits into from
Feb 17, 2021
Merged

Document that assert! format arguments are evaluated lazily #82169

merged 2 commits into from
Feb 17, 2021

Commits on Feb 16, 2021

  1. 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.
    not-an-aardvark committed Feb 16, 2021
    Configuration menu
    Copy the full SHA
    cb653b1 View commit details
    Browse the repository at this point in the history

Commits on Feb 17, 2021

  1. Configuration menu
    Copy the full SHA
    15197cb View commit details
    Browse the repository at this point in the history