We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e822c4 commit 32f308aCopy full SHA for 32f308a
packages/std/src/never.rs
@@ -7,6 +7,24 @@
7
///
8
/// Once the ! type is stable, this is not needed anymore.
9
/// See <https://github.com/rust-lang/rust/issues/35121>.
10
+///
11
+/// ## Examples
12
13
+/// When using `Never` in a `Result`, we can unwrap in a type-safe way:
14
15
+/// ```
16
+/// use cosmwasm_std::Never;
17
18
+/// pub fn safe_unwrap<T>(res: Result<T, Never>) -> T {
19
+/// match res {
20
+/// Ok(value) => value,
21
+/// Err(err) => match err {},
22
+/// }
23
24
25
+/// let res: Result<i32, Never> = Ok(5);
26
+/// assert_eq!(safe_unwrap(res), 5);
27
28
pub enum Never {}
29
30
// The Debug implementation is needed to allow the use of `Result::unwrap`.
0 commit comments