-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve PhantomData
held by curve adaptors
#15881
Conversation
I'm actually still a little bit unsure about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
PhantomData
instances 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/Sync
inference based onT
. See here.Solution
Switch to
PhantomData
of 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.