Crate expect_macro [] [src]

The expect! macro

This crate adds the expect! macro, which is basically just calling .expect on your type but also:

  • Includes the exact line number of the error
  • Allows you to specify a custom error message with formatting.

This gives you panic messages like this:

thread 'example' panicked at '"expect error"', src/lib.rs:5:5

As opposed to:

thread 'example' panicked at 'called `Result::unwrap()` on an `Err` value: "expect error"', libcore/result.rs:945:5

Macros

expect

Unwrap a result or panic! with a message.