pub trait InfallibleResultExt<T> {
// Required method
fn infallible_unwrap(self) -> T;
}
Expand description
This extension trait adds InfallibleResultExt::infallible_unwrap to Result types that use core::convert::Infallible as error type.
Required Methods§
Sourcefn infallible_unwrap(self) -> T
fn infallible_unwrap(self) -> T
This function does the same as Result::unwrap, but it only exists on types where the error type of the Result is core::convert::Infallible. This way, we can guarantee that this function will always be a no-op and will never panic. This is great for when your code style says that Result::unwrap is a code smell because it could cause runtime panics, but you need a safe alternative for it for when you know it can’t fail.