Re-opening deprecating Option::unwrap and Result::unwrap
Rust Internals [Unofficial]
February 25, 2026
CAD97:
There's a secondary argument that calling it
assert!leans too much intoTry/?being a "truthy"/"falsey" distinction, but the counterargument would be that the shape already exists anyway, and that defining assert in terms ofControlFlow::ContinuevsBreakstill makes sense.
I'd say that what you'd really want is
impl<T, E> Result<T, E> {
fn assert_ok(self) -> T;
fn assert_err(self) -> E;
}
impl<T> Option<T> {
fn assert_some(self) -> T;
fn assert_none();
}
It would be nice if those could be postfix macros which even allowed something like
let f = foo().assert_ok!("nice message {}", "with formatting");
or even
let f = bar().assert_ok!(err => "the error code was {}", err.code);
Discussion in the ATmosphere