File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ version = "0.1.0"
4
4
authors = [" Mikhail Zabaluev <mikhail.zabaluev@gmail.com>" ]
5
5
edition = " 2018"
6
6
license = " MIT OR Apache-2.0"
7
+ readme = " README.md"
7
8
8
9
[features ]
9
10
default = []
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments