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
As far as I can tell, from the point of view of lifetimes, PhantomData<T> should behave identically to T. This is unfortunately not the case in practice.
This function causes a mismatched type error on x:
fn cast_phantom<'a, 'b, T>(x: PhantomData<&'a T>) -> PhantomData<&'b T> where 'a : 'b {
x
}
Whereas this similar function does not:
fn cast_actual<'a, 'b, T>(x: &'a T) -> &'b T where 'a : 'b {
x
}
The variance rules of lifetimes should make both functions valid.