-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Infer StableInterpolate
on tuples
#15931
Infer StableInterpolate
on tuples
#15931
Conversation
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.
Can you add the fake_variadics doc attribute? We've added this elsewhere and it really improves the rustdoc output.
I would suggest using the all_tuples macro here, but it's good to not pull in that dependency.
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.
Kind of cursed, but it does look like this is the only way without introducing new deps.
could you try to use https://docs.rs/bevy/latest/bevy/utils/macro.all_tuples.html? |
Do you know how to do that outside of the context of the
It doesn't work anyway :( I spent quite a while trying to do it that way and reached the conclusion that it's basically impossible. |
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.
I'm fine with this for now :)
@BenjaminBrienen @bash y'all have any advice? You were very helpful for this in #15387 |
For what it's worth, I got it working with a new version of |
I had the same errors he's describing. It only worked for me within |
Follow-up it is then ;) |
Yeah |
This is a follow-up to #15931 that adds `#[doc(fake_variadic)]` for improved docs output :)
Objective
Make
StableInterpolate
"just work" on tuples whose parts are eachStableInterpolate
types. These types arise notably throughCurve::zip
(or just through explicit mapping of a similar form). It would otherwise be kind of frustrating to stumble upon such a thing and then realize that, e.g., automatic resampling just doesn't work, even though there is a very "obvious" way to do it.Solution
Infer
StableInterpolate
on tuples of up to size 11. I can make that number bigger, if desired. Unfortunately, I don't think that our standard "fake variadics" tools actually work for this; the anonymous field accessors of tuples are:tt
for purposes of macro expansion, which means that you can't simplify away the identifiers by doing something clever like using recursion (which would work if they were:expr
). Maybe someone who knows some incredibly dark magic could chime in with a better solution.The expanded impls look like this:
Testing
Expanded macros; it compiles.
Future
Make a version of the fake variadics workflow that supports this kind of thing.