#never-type #conversion #refactoring #infallible #maintainability


Unwrapping Result values with compile-time guarantee of infallibility

6 releases

0.1.5 Dec 16, 2019
0.1.4 Dec 11, 2019
0.1.3 Nov 9, 2019
0.1.2 Oct 31, 2019

#699 in Rust patterns

Download history 4775/week @ 2022-12-01 5024/week @ 2022-12-08 5676/week @ 2022-12-15 1959/week @ 2022-12-22 2597/week @ 2022-12-29 5332/week @ 2023-01-05 5545/week @ 2023-01-12 5357/week @ 2023-01-19 6977/week @ 2023-01-26 6915/week @ 2023-02-02 7212/week @ 2023-02-09 7377/week @ 2023-02-16 7094/week @ 2023-02-23 7134/week @ 2023-03-02 5209/week @ 2023-03-09 3657/week @ 2023-03-16

24,731 downloads per month
Used in 3 crates


53 lines

Unwrapping Results With Compile-Time Guarantee of Infallibility

The Rust standard type Result sometimes occurs parameterized with an error type that has no possible values, such as std::convert::Infallible. Consequently, calling the unwrap method on a Result value of such a type will never panic. Therein lies a maintainability hazard: if the error parameter type is later changed to one that can represent actually occurring errors, those uses of unwrap that could previously be relied upon to be infallible, quietly become liable to panic.

To help prevent this from happening without a compile-time safeguard, this crate provides an alternative method unwrap_infallible that shall only be available for Result values with a known-impossible Err variant.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps


  • blanket_impl
  • never_type
  • unstable