2 stable releases

6.6.666 Jan 19, 2022

#1692 in Rust patterns

Download history 10219/week @ 2024-07-24 10084/week @ 2024-07-31 9216/week @ 2024-08-07 10005/week @ 2024-08-14 10996/week @ 2024-08-21 11068/week @ 2024-08-28 11837/week @ 2024-09-04 9837/week @ 2024-09-11 9273/week @ 2024-09-18 11821/week @ 2024-09-25 13041/week @ 2024-10-02 10902/week @ 2024-10-09 15462/week @ 2024-10-16 13382/week @ 2024-10-23 13042/week @ 2024-10-30 9214/week @ 2024-11-06

53,259 downloads per month
Used in 40 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