macro_rules! assert_some_eq { ($cond:expr, $expected:expr,) => { ... }; ($cond:expr, $expected:expr) => { ... }; ($cond:expr, $expected:expr, $($arg:tt)+) => { ... }; }
Expand description
Asserts that left expression returns Some(T)
variant
and its value of T
type equals to the right expression.
§Uses
Assertions are always checked in both debug and release builds, and cannot be disabled.
See debug_assert_some_eq!
for assertions that are not enabled in release builds by default.
§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
let maybe = Some(42);
assert_some_eq!(maybe, 42);
// With custom messages
assert_some_eq!(maybe, 42, "Got some value");
None
variant will cause panic:
ⓘ
let maybe: Option<i32> = None;
assert_some_eq!(maybe, 42); // Will panic