2 stable releases

6.6.666 Jan 19, 2022

#1733 in Rust patterns

Download history 11175/week @ 2024-08-16 10077/week @ 2024-08-23 11644/week @ 2024-08-30 11547/week @ 2024-09-06 7991/week @ 2024-09-13 11573/week @ 2024-09-20 10927/week @ 2024-09-27 13569/week @ 2024-10-04 12864/week @ 2024-10-11 14023/week @ 2024-10-18 13412/week @ 2024-10-25 11812/week @ 2024-11-01 10194/week @ 2024-11-08 11028/week @ 2024-11-15 15221/week @ 2024-11-22 17855/week @ 2024-11-29

56,184 downloads per month
Used in 45 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