Closed ckaran closed 2 years ago
OK, I created a PR for this (#11), but realized that I have no idea how to deal with the never type. The issue is that I want to make the implementation's existence contingent on someone activating the never feature via #![feature(never_type)]
. Unfortunately, using cfg
the way I thought it would work, doesn't actually work. Any ideas?
Which traits concretely are you thinking about implementing for never
?
Everything except LayoutAs
. I think that because !
can coerce into any type, it can also coerce to a slice type, and since the documentation for !
states that we should implement all traits for it, I think it makes to sense to follow the docs and implement everything except for LayoutAs
.
OK, I managed to sort of get it to work, but I discovered that it can't be tested because the never type has no values. That makes it impossible to write it out, and makes it impossible to verify that you've read it back in correctly. So, I'm not sure how we're supposed to add traits to it. I mean, I can add the appropriate traits to it, but then we can't do anything with them... should we close this issue?
sounds good. If we really end up needing it for something, we can still add it.
OK, I'm going to close this issue for now. If it needs to be reopened in the future, we can always do so then.
OK, I'm going to close this issue for now. If it needs to be reopened in the future, we can always do so then.
Both
unit
(()
) andnever
(!
) are zero-sized types, so there isn't any true binary representation for them. That said, they are primitive types, anddefine_layout!()
could in theory encounter one (or both) of them. In addition, the documentation fornever
says that we should implement non-panicing traits for it whenever possible. Would it make sense to implement all the various traits for them exceptLayoutAs
? My thought is that they accept and produce slices of zero length, which shouldn't cause any issues.