This repository was archived by the owner on Dec 17, 2025. It is now read-only.
Struct generation improvements#81
Merged
VictorKoenders merged 5 commits intobincode-org:trunkfrom Jan 16, 2024
Merged
Conversation
Adds the possibility to make ZST structs and structs with unnamed fields. Backwards compability is insured by defaulting to `StructType::Named`, which causes identical behaviour to before.
Adds an enum generator, based on the struct generator.
Previously, structs could only be generated inside a new module. Sometimes, it is desirable to define a new struct in the same module as the struct that is being derived on. By dupicating the `generate_struct` function from `GenerateMod` to to `Generator`, this is easily achieved.
Contributor
|
Would you mind adding examples that will also validate the generated code? An example can be found here |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## trunk #81 +/- ##
==========================================
- Coverage 48.42% 46.23% -2.20%
==========================================
Files 20 21 +1
Lines 2030 2124 +94
==========================================
- Hits 983 982 -1
- Misses 1047 1142 +95 ☔ View full report in Codecov by Sentry. |
Contributor
Author
|
I have added doc comment tests that I believe cover all of the added functionality. Please let me know if I missed anything! |
Add testcases for the struct and enum generators.
A Tuple struct is called a Tuple struct, not an unnamed field struct, so it makes more sense for the function to be called `make_tuple`, in line with `make_ZST`.
Contributor
|
Thanks! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR includes multiple improvements to virtue regarding the generation of Structs and Enums:
struct StructName;).Points 2 and 3 have been previously raised in https://github.com/bincode-org/virtue/issues/23.
Point 1 is just something I ran into personally.