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

Automatically determine entry type instead of manually checking. #4

Open
GanShun opened this issue Mar 16, 2022 · 0 comments
Open

Automatically determine entry type instead of manually checking. #4

GanShun opened this issue Mar 16, 2022 · 0 comments

Comments

@GanShun
Copy link
Contributor

GanShun commented Mar 16, 2022

From @daym:
Possible way to automate at least checking whether we forgot one here (steps):

Generate an enum with all the structs a la ElementRef--which we are already doing in the ondisk.rs for some of the items.
match here.
Maybe find out whether ElementAsBytes and/or SequenceElementAsBytes or the respective other traits are implemented for some struct and thus sanity-check this here.

Distinguishing those would be possible by using more specific macros than make_accessors, or adding an obvious parameter to make_accessors would could be seen by a macro that's called at the toplevel

record_structs! {
make_type1_accessors! {
struct Foo {
}
}
make_type2_accessors! {
struct Foo {
}
}
}

and have record_structs match on patterns make_type1_accessors in one branch, make_type2_accessors in another branch (lazily--but that is how it is anyway), and result in one enum for all the type1, another enum for all the type2. Then use those.

Alternatively (and much less ugly), try using enum_dispatch.

From @GanShun:
I think I tried enum dispatch at one point, but it doesn't work with remote traits, so we'll need to find some way to work around that.

@GanShun GanShun self-assigned this Mar 16, 2022
@cio-bot cio-bot bot unassigned GanShun Jun 29, 2022
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

No branches or pull requests

1 participant