2 stable releases

6.6.666 Jan 19, 2022

#1638 in Rust patterns

Download history 16833/week @ 2024-06-06 15996/week @ 2024-06-13 20581/week @ 2024-06-20 21908/week @ 2024-06-27 12535/week @ 2024-07-04 10593/week @ 2024-07-11 12190/week @ 2024-07-18 10094/week @ 2024-07-25 10200/week @ 2024-08-01 9077/week @ 2024-08-08 11016/week @ 2024-08-15 10599/week @ 2024-08-22 11135/week @ 2024-08-29 11571/week @ 2024-09-05 8871/week @ 2024-09-12 8143/week @ 2024-09-19

42,060 downloads per month
Used in 29 crates (6 directly)

Zlib OR MIT OR Apache-2.0

8KB

::never-say-never

Repository Latest version Documentation MSRV unsafe forbidden License CI

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 {}.

That is, the following fails to compile:

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!

use ::never_say_never::Never;

let x: u32 = match Ok::<_, Never>(42) {
    | Ok(it) => it,
    | Err(unreachable) => unreachable,
};

No runtime deps