This repository was archived by the owner on Aug 15, 2025. It is now read-only.
Make bincode_derive 0 dependencies#409
Merged
VictorKoenders merged 24 commits intofeature/deserdefrom Oct 12, 2021
Merged
Conversation
…implemented lifetime dependencies
ghost
suggested changes
Oct 7, 2021
Codecov Report
@@ Coverage Diff @@
## feature/deserde #409 +/- ##
====================================================
- Coverage 87.68% 66.48% -21.20%
====================================================
Files 16 29 +13
Lines 958 1886 +928
====================================================
+ Hits 840 1254 +414
- Misses 118 632 +514
Continue to review full report at Codecov.
|
ghost
reviewed
Oct 12, 2021
|
Looks like this parser can't handle field attributes (i.e. |
ghost
reviewed
Oct 12, 2021
ghost
approved these changes
Oct 12, 2021
…ade bincode_derive ignore attributes
19 tasks
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 removes
syn,proc_macro2andquotefrombincode_derive.We still have to keep
proc_macro2as a dev dependency as it is otherwise impossible to test the parser. This is automatically used instead ofproc_macrowhen running tests.The change is roughly split into 2 parts:
Parsing
Most of parsing is done in the
derive/src/parse/folder. This will generate the following types:Visibility, not being used currentlyDataTypeeitherStructorEnum, with the name of the data type being parsedGenericsthe generics part of the type, e.g.struct Foo<'a>GenericConstraintsthe "where" part of the typeGenerate
Generating the code implementation is done in either
derive/src/derive_enum.rsandderive/src/derive_struct.rs.This is supported by the structs in
derive/src/generate. The most notable points of this module are:StreamBuilderis a thin but friendly wrapper aroundTokenStreamGeneratoris the base type of the code generator. This has helper methods to generate implementations:ImplForis a helper struct for a singleimpl A for Bconstruction. In this functions can be defined:GenerateFnBodyis a helper struct for a single function in the aboveimpl. This is created with a callback toFnBuilderwhich helps set some properties.GenerateFnBodyhas astream()function which returnsStreamBuilderfor the function.The code is tested against the current cases in
tests/derive.rs, however we'll need a lot more test cases before this PR can be merged.For testing purposes, all generated code is outputted to the current
targetfolder, under file name<struct/enum name>_Encodeable.rsand<struct/enum name>_Decodeable.rs. This can help with debugging.