# 1.0.0[−][src]Macro core::assert

    macro_rules! assert {
        ($cond:expr) => { ... };
        ($cond:expr,) => { ... };
        ($cond:expr, $($arg:tt)+) => { ... };
    }

Asserts that a boolean expression is `true` at runtime.

This will invoke the `panic!` macro if the provided expression cannot be evaluated to `true` at runtime.

# Uses

Assertions are always checked in both debug and release builds, and cannot be disabled. See `debug_assert!` for assertions that are not enabled in release builds by default.

Unsafe code relies on `assert!` to enforce run-time invariants that, if violated could lead to unsafety.

Other use-cases of `assert!` include testing and enforcing run-time invariants in safe code (whose violation cannot result in unsafety).

# Custom Messages

This macro has a second form, where a custom panic message can be provided with or without arguments for formatting. See `std::fmt` for syntax for this form.

# Examples

    // the panic message for these assertions is the stringified value of the
    // expression given.
    assert!(true);

    fn some_computation() -> bool { true } // a very simple function

    assert!(some_computation());

    // assert with a custom message
    let x = true;
    assert!(x, "x wasn't true!");

    let a = 3; let b = 27;
    assert!(a + b == 30, "a = {}, b = {}", a, b);Run

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)