Re-opening deprecating Option::unwrap and Result::unwrap
Rust Internals [Unofficial]
February 25, 2026
FWIW, without providing the error value, there's not much difference[1] between that and
let Ok(f) = foo() else { panic!("nice message {}", "with formatting") };
but yes, a postfix .unwrap! would be a very nice convenience. There are just many issues with type-dependent macro name lookup that make this an unlikely feature. (.unwrap! could potentially be non-type-dependent by being generic over Try semantics, but .assert_ok! wouldn't want to be a global name that only accepts Result receivers. You could maybe argue justifying it from the fact that Ok is already in the prelude, but that's a rather weak justification.)
- At least, if we stray from rustfmt's default style, which always makes the
elseblock an indented block. ↩︎
Discussion in the ATmosphere