Fix custom functions for optional number types#315
Merged
Conversation
Round-tripping these through `quote!().to_token_stream().to_string()` lets us ensure that the resulting strings always match. Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
6696839 to
0482b99
Compare
Keats
approved these changes
Mar 28, 2024
| quote!(f64), | ||
| ]; | ||
| let mut tys = Vec::with_capacity(number_types.len() * 3); | ||
| for ty in number_types { |
Owner
There was a problem hiding this comment.
for loop are still not available in const fn right? :(
Contributor
Author
There was a problem hiding this comment.
That can be worked around by using a while loop, the bigger issue is that we can't use to_string() because trait methods can't be const yet, and I think quote!() also doesn't work in const fns. (Which is actually the reason for loops can't be used as well.)
Keats
pushed a commit
that referenced
this pull request
Apr 5, 2024
* Dynamically build the list of number types Round-tripping these through `quote!().to_token_stream().to_string()` lets us ensure that the resulting strings always match. Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> * Don't destructure number types by reference Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> * Add test for custom fns on number types not taking a reference Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com> --------- Signed-off-by: Johannes Löthberg <johannes.loethberg@elokon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.