I am trying to figure out what exactly is the effect of adding
PhantomData to my program. I understood what’s going on with unused lifetime parameters, and how
PhantomData helps Rust infer the right variance of the type.
However, the documentation mentions two more use-cases for
PhantomData, that are about ownership. In particular, the paragraph “Indicating ownership” is slightly puzzling. I understand that
*mut T does not imply any kind of ownership of a
PhantomData<T> does. But what I’d like to know is - why should I care? What exactly is Rust doing differently when I add a
PhantomData<T> to my unsafe container managing data of type
If you’d like to see example code, here it is.
PhantomData, but I don’t actually know why, or what would go wrong if I would remove it.