Crates.io | unwrap-infallible |
lib.rs | unwrap-infallible |
version | 0.1.5 |
source | src |
created_at | 2019-10-30 05:43:39.691953 |
updated_at | 2019-12-16 09:21:45.347439 |
description | Unwrapping Result values with compile-time guarantee of infallibility |
homepage | |
repository | https://github.com/mzabaluev/unwrap-infallible |
max_upload_size | |
id | 176852 |
size | 17,976 |
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.