We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
unwrap
unwrap_unchecked
1 parent d2211c9 commit 516da4cCopy full SHA for 516da4c
library/std/src/io/error.rs
@@ -844,9 +844,13 @@ impl Error {
844
ErrorData::Custom(b) if b.error.is::<E>() => {
845
let res = (*b).error.downcast::<E>();
846
847
- // Safety: b.error.is::<E>() returns true,
848
- // which means that res must be Ok(e).
849
- Ok(unsafe { res.unwrap_unchecked() })
+ // downcast is a really trivial and is marked as inline, so
+ // it's likely be inlined here.
+ //
850
+ // And the compiler should be able to eliminate the branch
851
+ // that produces `Err` here since b.error.is::<E>()
852
+ // returns true.
853
+ Ok(res.unwrap())
854
}
855
repr_data => Err(Self { repr: Repr::new(repr_data) }),
856
0 commit comments