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

Support types with const generics #179

Closed
wants to merge 2 commits into from

Conversation

SpencerSharkey
Copy link
Contributor

@SpencerSharkey SpencerSharkey commented Oct 12, 2022

Before this change, const generic parameters were ignored when generating a title for a type's schema.

I propose we treat const generic parameters similar to generic type parameters. Since const generics are simple expressions that fit into the format macro arguments, we can use the literal value in the name of the type. This parameterizes the unique permutations of a type and it's const generics as separate definitions, in case those const generics are used as properties of the schema.

Tests were added to ensure naming works, including templating the overwritten with the rename attribute.

Note: Since the MSRV is 1.45, I added a check around the test cases involving const generics. Since this change doesn't actually use const generics (landed in 1.51), we can still support if the user's rust version supports the feature. I was looking to use const generics for the JsonSchema array impls ([T; SIZE]), but we cannot do that with the current MSRV :)

@GREsau
Copy link
Owner

GREsau commented Aug 27, 2023

Thanks, this has been merged in #239 (conflicts fixed and MSRV is now 1.56 so no need for the version check)

@GREsau GREsau closed this Aug 27, 2023
@SpencerSharkey SpencerSharkey deleted the const-generics branch August 27, 2023 19:52
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.

None yet

2 participants