{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreidg4cahiz65zflo4g5rwacddu2p45beadd7m5ghtixcbfvac7txfq",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mfppspo24uk2"
},
"path": "/t/re-opening-deprecating-option-unwrap-and-result-unwrap/23734?page=7#post_122",
"publishedAt": "2026-02-25T20:23:24.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "CAD97:\n\n> There's a secondary argument that calling it `assert!` leans too much into `Try`/`?` being a \"truthy\"/\"falsey\" distinction, but the counterargument would be that the shape already exists anyway, and that defining assert in terms of `ControlFlow::Continue` vs `Break` still makes sense.\n>\n> * * *\n\nI'd say that what you'd really want is\n\n\n impl<T, E> Result<T, E> {\n fn assert_ok(self) -> T;\n fn assert_err(self) -> E;\n }\n\n impl<T> Option<T> {\n fn assert_some(self) -> T;\n fn assert_none();\n }\n\n\nIt would be nice if those could be postfix macros which even allowed something like\n\n\n let f = foo().assert_ok!(\"nice message {}\", \"with formatting\");\n\n\nor even\n\n\n let f = bar().assert_ok!(err => \"the error code was {}\", err.code);\n",
"title": "Re-opening deprecating Option::unwrap and Result::unwrap"
}