4 ms·
One minor note is that I don't think PhantomData is required here. _state: PhantomData<State> Since State is zero-sized it is free to store it in the struct
by kevincox 6y ago
One minor note is that I don't think PhantomData is required here.
_state: PhantomData<State>
Since State is zero-sized it is free to store it in the struct.
state: State
IIUC PhantomData is only required when you need to indicate that you are logically storing something of that type but don't want to actually store it. Since storing is free in this case you may as well just store it.
- lilyball 6y agoThis sounds reasonable, but personally I prefer the PhantomData as it makes it immediately obvious to the reader that this is a zero-sized type.