#say #ever #never #flying-pigs

never-say-never

The never type (the true one!) in stable Rust

2 stable releases

6.6.666 Jan 19, 2022

#1 in #ever

Download history 16678/week @ 2024-12-14 6501/week @ 2024-12-21 6572/week @ 2024-12-28 15916/week @ 2025-01-04 20063/week @ 2025-01-11 19417/week @ 2025-01-18 19284/week @ 2025-01-25 28818/week @ 2025-02-01 32185/week @ 2025-02-08 18998/week @ 2025-02-15 25291/week @ 2025-02-22 27630/week @ 2025-03-01 33525/week @ 2025-03-08 39573/week @ 2025-03-15 34156/week @ 2025-03-22 28504/week @ 2025-03-29

140,801 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