2 stable releases

6.6.666 Jan 19, 2022

#1696 in Rust patterns

Download history 14548/week @ 2024-11-21 17068/week @ 2024-11-28 19232/week @ 2024-12-05 19367/week @ 2024-12-12 10052/week @ 2024-12-19 5305/week @ 2024-12-26 12770/week @ 2025-01-02 18614/week @ 2025-01-09 18986/week @ 2025-01-16 19052/week @ 2025-01-23 26139/week @ 2025-01-30 32635/week @ 2025-02-06 22500/week @ 2025-02-13 23173/week @ 2025-02-20 27289/week @ 2025-02-27 30765/week @ 2025-03-06

110,945 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