Skip to content

Commit 0582eef

Browse files
committed
Added README
1 parent db6a682 commit 0582eef

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.0"
44
authors = ["Mikhail Zabaluev <mikhail.zabaluev@gmail.com>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"
7+
readme = "README.md"
78

89
[features]
910
default = []

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Unwrapping Results With Compile-Time Guarantee of Infallibility
2+
3+
The Rust standard type `Result` sometimes occurs parameterized
4+
with an error type that has no possible values, such as
5+
`std::convert::Infallible`. Consequently, calling the `unwrap` method on a
6+
`Result` value of such a type will never panic.
7+
Therein lies a maintainability hazard: if the error parameter type is later
8+
changed to one that can represent actually occurring errors, those uses of
9+
`unwrap` that could previously be relied upon to be infallible, quietly
10+
become liable to panic.
11+
12+
To help prevent this from happening without a compile-time safeguard,
13+
this crate provides an alternative method `unwrap_infallible` that shall only
14+
be available for `Result` values with a known-impossible `Err` variant.
15+
16+
## License
17+
18+
Licensed under either of
19+
20+
* Apache License, Version 2.0
21+
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
22+
* MIT license
23+
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
24+
25+
at your option.
26+
27+
## Contribution
28+
29+
Unless you explicitly state otherwise, any contribution intentionally submitted
30+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
31+
dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)