1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*!
# `::never-say-never`
[](
https://github.com/danielhenrymantilla/never-say-never.rs)
[](
https://crates.io/crates/never-say-never)
[](
https://docs.rs/never-say-never)
[](
https://gist.github.com/danielhenrymantilla/8e5b721b3929084562f8f65668920c33)
[](
https://github.com/rust-secure-code/safety-dance/)
[](
https://github.com/danielhenrymantilla/never-say-never.rs/blob/master/LICENSE-ZLIB)
[](
https://github.com/danielhenrymantilla/never-say-never.rs/actions)
<!-- Templated by `cargo-generate` using https://github.com/danielhenrymantilla/proc-macro-template -->
The `!` type. In stable Rust. Since `1.14.0`.
Better than an `enum Never {}` definition would be, since an instance of
type `!` automagically coerces to any type, whereas an instance of
`enum EmptyEnum {}` needs an explicit `match it {}`.
- Currently, [`::core::convert::Infallible`] is a sad instance of the
latter.
[`::core::convert::Infallible`]: https://doc.rust-lang.org/1.58.0/core/convert/enum.Infallible.html
That is, the following fails to compile:
```rust ,compile_fail
let x: u32 = match <u32 as TryFrom<u8>>::try_from(42) {
| Ok(it) => it,
| Err(unreachable) => unreachable, // Error, expected `u32`, found `Infallible`
};
```
but the following doesn't!
```rust
use ::never_say_never::Never;
let x: u32 = match Ok::<_, Never>(42) {
| Ok(it) => it,
| Err(unreachable) => unreachable,
};
```
*/
/// Workaround for `fn_traits` and/or `unboxed_closures`
/// The `!` type. See [the main docs for more info][`crate`].
pub
type Never =
as
FnOnce
>Output;