pub const fn expect_ok<T, E>(res: Result<T, E>, message: &str) -> TExpand description
Const version of Result::expect without the Debug formatting.
Can also be used in combination with Result::is_ok to match the result.
ยงExample
use const_util::result::expect_ok;
const fn double<E>(res: Result<i32, E>) -> Result<i32, E> {
if res.is_ok() {
Ok(2 * expect_ok(res, "Unreachable"))
} else {
res
}
}
assert_eq!(double(Ok::<_, String>(1)), Ok(2));