Commit 1c2d22c
feat(stackable-versioned): Generate From implementations for automatic versions upgrades (#790)
* Add basic From impl generation
* Merge branch 'main' into feat/crd-versioning-from-impls
* Separate code, re-add basic From impl, separate generation code
This commit separate the code into two crates: the
core stackable-versioned crate, which provides a
few utility traits and types and also re-exports
the macros from the stackable-versioned-macros
crate. This is because, crates (or libraries)
marked as proc-macro libraries don't support
export anything other than macro items.
It also re-adds the basic From impl which was hard
to keep across the previous merge conflict. This
basic impl will currently panic, as the inner
function is not yet implemented. This will follow.
It additionally separates the generation code into
multiple functions to more easily generate the
different parts of code, like modules, struct
fields and From impls.
* Generate working inner From trait function
There is at least one known rough edge: The #[allow(deprecated)]
attribute is always included in the generated output, regardless
if the individual From implementation actually needs it. The
attribute is only required when the next version of the struct
includes a field which is marked as deprecated.
* Add option to skip From trait implementation generation
Can be skipped both on the container level (no impls are generated)
or at the version level (no impls are generated for that version).
* Add README
* Add basic support for custom default function
* Fix doc test
* Add TODOs
* Start adding doc comments
* Finish doc comment
* Fix changelog
* Fix doc tests
* Update crates/stackable-versioned-macros/src/lib.rs
Co-authored-by: Nick <NickLarsenNZ@users.noreply.github.com>
* Remove redundant code block in doc comment
---------
Co-authored-by: Nick <NickLarsenNZ@users.noreply.github.com>1 parent 84646f2 commit 1c2d22c
19 files changed
Lines changed: 791 additions & 234 deletions
File tree
- crates
- stackable-versioned-macros
- src
- attrs
- gen
- tests
- stackable-versioned
- src
- gen
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
| 104 | + | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
101 | 119 | | |
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
43 | 54 | | |
44 | 55 | | |
45 | 56 | | |
| |||
139 | 150 | | |
140 | 151 | | |
141 | 152 | | |
| 153 | + | |
142 | 154 | | |
143 | 155 | | |
144 | 156 | | |
| |||
File renamed without changes.
File renamed without changes.
0 commit comments