fix: derive dynamic RustSBI on struct with generics(type, const, lifetime, where clause) #68
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.
In PR #67 , a RustSBI macro implementation that can be processed dynamically has been added.
But the current implementation has some problems. Take the following struct as an example.
The macro code cannot compile this struct because its
strcut prober
struct does not handle lifetime situations. In fact, all generics are not handled, including lifetime, type generics, constant generics, and where clauses. These problems limit the application ofrustsbi dynamic
in actual projects.This pull request solves the problem of generics not being processed. The definition of
struct _Prober
is extended to include generics, which is composed of impl generics, type generics and where clause. We add them to the generated code ofstruct _Prober
, thus solving the problem.Until now,
rustsbi dynamic
can be used for struct with lifetime, and its application scope will be expanded.In order to verify the effectiveness of this modification, an additional unit test module(
tests/dynamic-generics.rs
) has been added. All structures in this unit test file contain different types of generics to comprehensively test the correctness of the macro generated code, thereby verifying the repair results of this pull request.