Re:Never patterns, exhaustive matching, and uninhabited type...
by ChrisSD on Saturday August 18, 2018 @08:48AM
(#17788219)
I've used `enum Void { }` as a placeholder for opaque FFI managed types that I pass between APIs but never inspect myself. Like Windows handles (`*const Void`) or data structures that are queried using an API rather than directly.
[ Parent
| on HN ]
Re:Never patterns, exhaustive matching, and uninhabited type...
by nalllar on Saturday August 18, 2018 @09:51AM
(#17788448)
enum Void shouldn't be used for opaque types.
See these: https://internals.rust-lang.org/t/recent-change-to-make-exha... https://github.com/rust-lang-nursery/nomicon/issues/29 https://github.com/briansmith/ring/issues/416
Re:Never patterns, exhaustive matching, and uninhabited type...
by ChrisSD on Saturday August 18, 2018 @09:54AM
(#17788464)
Oh wow, I didn't know this. At one time at least it was recommended, which was why I did it.
Re:Never patterns, exhaustive matching, and uninhabited type...
by bjz_ on Saturday August 18, 2018 @10:31AM
(#17788610)
Yeah, IIRC many years ago I added it in a document as a pattern for C APIs (I can't remember where though). Either other people were doing the same thing, or were influenced by that. Anyway, you should use `*const libc::void` these days! Sorry for the confusion.