pub trait ExpectUnchecked<T> {
// Required method
unsafe fn expect_unchecked(self, msg: &str) -> T;
}Expand description
Extracts successful values through an unchecked result assertion.
Debug builds retain an assertion for the error branch. Release builds rely entirely on the caller’s safety guarantee.
Required Methods§
Sourceunsafe fn expect_unchecked(self, msg: &str) -> T
unsafe fn expect_unchecked(self, msg: &str) -> T
Returns the contained Ok value without a release-mode branch check.
Debug builds use msg when asserting that the result is successful.
Release builds treat an Err value as unreachable.
§Panics
Panics in debug builds when the result is Err.
§Safety
The caller must guarantee the result is not Err; violating this in
release builds causes undefined behavior.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".