ELSEIF
Your brief EB
1,616 stories from 222 feeds 1278 clusters Refreshed 3 minutes ago next pull 16:11

LANGUAGES Signal 124

Rust's new ! type is an empty type, not bottom, so nested ! won't coerce

Illustration only Photo by Eugen Str on Unsplash

Rust's recently added ! type behaves as an empty type rather than a bottom type, so coercion only works for top-level ! expressions, not when ! is nested inside other types like function pointers.

WHY IT MATTERS

For Rust developers, this means that while you can use ! in any type annotation, you cannot rely on implicit coercion when ! appears inside a larger type, such as a function pointer. This makes some code more verbose, requiring explicit coercion at the point where the ! value is used. Understanding the distinction between empty and bottom types helps avoid surprises when writing generic or higher-order functions.

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

Rust now allows the never type ! in all type annotations, not just return types.

02

Unlike a bottom type, Rust's ! does not coerce when nested inside other types like function pointers.

03

To use a nested !, you must explicitly coerce the value at the point of use, as Rust lacks subtyping.

THE CLUSTER

Same story, 1 feed.

ORDERED BY FIRST SEEN
ettolrach.com via Lobsters Rust: When Empty Isn't Bottom Open ↗