Improve PhantomData held by curve adaptors#15881
Improve PhantomData held by curve adaptors#15881alice-i-cecile merged 2 commits intobevyengine:mainfrom
PhantomData held by curve adaptors#15881Conversation
|
I'm actually still a little bit unsure about |
MrGVSV
left a comment
There was a problem hiding this comment.
My brain struggles so hard with trying to understand variance, but this looks right to me
When would |
It's often regarded as good practice not to include trait bounds on struct definitions unless they are required for the struct itself to make sense (e.g. by using associated types in fields). (If anything, this helps avoid needless duplication of trait bounds, but there are other reasons as well.) |
Objective
The previous
PhantomDatainstances were written somewhat lazily, so they were just things likePhantomData<T>for curves with an output type ofT. This looks innocuous, but it unnecessarily constrainsSend/Syncinference based onT. See here.Solution
Switch to
PhantomDataof the formPhantomData<fn() -> T>for most of these adaptors. Since they only have a functional relationship toT(i.e. it shows up in the return type of trait methods), this is more accurate.Testing
Tested by compiling Bevy.