this post was submitted on 11 Dec 2025
32 points (100.0% liked)
Rust
7566 readers
7 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
This is impossible. How would you enforce that? What prevents a function from panicking, aborting the whole process or just going into an infinite loop? All these things correspond to the never type.
I think you're misunderstanding what the never type is. It's not equivalent to None at all. It's a type that doesn't have any values. This is useful in situations with generic code where for example an error type can be chosen as the never type. Then you could destructure or unwrap a Result without handling the error, cause the type system guarantees the error never occurs.
I think you should read up on the never type a bit more. It's a perfectly natural part of the type system. In fact you can make your own very easily:
enum Never {}