Skip to content
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

Fix custom functions for optional number types #315

Merged
merged 3 commits into from
Mar 29, 2024

Conversation

kyrias
Copy link
Contributor

@kyrias kyrias commented Mar 28, 2024

No description provided.

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>
quote!(f64),
];
let mut tys = Vec::with_capacity(number_types.len() * 3);
for ty in number_types {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for loop are still not available in const fn right? :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Keats merged commit 01229b9 into Keats:fix-bugs Mar 29, 2024
0 of 4 checks passed
@kyrias kyrias deleted the computed-number-types branch March 29, 2024 15:18
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants