Skip to content

Unwrap infallible results with all convenience and no fear

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

mzabaluev/unwrap-infallible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

License

Licensed under either of

at your option.

Contribution

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.

About

Unwrap infallible results with all convenience and no fear

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages