You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Never types are types used as a placeholder when the thing they represent is not needed.
They are used in the following cases in neo datetime:
The absence of a calendar (NeverCalendar)
When a field is not needed or returned for a field set (NeverField)
When a data payload is not to be loaded (NeverMarker)
Some, but not all, of the time, these can be the unit type (). However, when they need to implement a trait, it is sometimes required that they be their own type, since there are restrictions to implementing traits on standard library types (unless we restrict ourselves to using only our own traits).
I try my best to hide these so that they don't show up in user code, but they are part of public API and they could end up there in some cases.
Help me decide:
Should there be one Never type per crate or one per use case?
Should I prefer () always (even if it means a less natural trait impl), Never always (even if () could have been used), or decide on a case-by-case basis?
Should they be named Phantom instead of Never? We use the word "never" in some enums to mean "never show the sign", for example, and "NeverCalendar" just looks weird; "PhantomCalendar" might be more intuitive.
This probably blocks 2.0 beta because I need to name these things.
I think Never as "a type level Option::None" is a good association, and having NeverMarker as a global thing works nicely. I think it's good to use () where possible, even if it's a little clunky (but we can discuss if it feels super clunky).
I think Phantom means something different from Never, Phantom has a much stronger association towards low level abstractions and variance for me in Rust.
Never types are types used as a placeholder when the thing they represent is not needed.
They are used in the following cases in neo datetime:
Some, but not all, of the time, these can be the unit type
()
. However, when they need to implement a trait, it is sometimes required that they be their own type, since there are restrictions to implementing traits on standard library types (unless we restrict ourselves to using only our own traits).I try my best to hide these so that they don't show up in user code, but they are part of public API and they could end up there in some cases.
Help me decide:
()
always (even if it means a less natural trait impl),Never
always (even if()
could have been used), or decide on a case-by-case basis?Phantom
instead ofNever
? We use the word "never" in some enums to mean "never show the sign", for example, and "NeverCalendar" just looks weird; "PhantomCalendar" might be more intuitive.This probably blocks 2.0 beta because I need to name these things.
@robertbastian @Manishearth
The text was updated successfully, but these errors were encountered: