2 stable releases

6.6.666 Jan 19, 2022

#1638 in Rust patterns

Download history 12701/week @ 2024-11-03 8778/week @ 2024-11-10 12298/week @ 2024-11-17 15695/week @ 2024-11-24 18218/week @ 2024-12-01 20917/week @ 2024-12-08 16562/week @ 2024-12-15 7028/week @ 2024-12-22 5867/week @ 2024-12-29 16192/week @ 2025-01-05 19837/week @ 2025-01-12 19656/week @ 2025-01-19 19447/week @ 2025-01-26 29813/week @ 2025-02-02 31664/week @ 2025-02-09 4140/week @ 2025-02-16

85,510 downloads per month
Used in 47 crates (7 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