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

Support flattening attributes #10

Open
ecton opened this issue Apr 11, 2023 · 2 comments
Open

Support flattening attributes #10

ecton opened this issue Apr 11, 2023 · 2 comments

Comments

@ecton
Copy link

ecton commented Apr 11, 2023

Similar to #4, I'm adding a new attribute for ViewSchema and want to share the view() identifier name, so that all the parameters just live on the same level, but I can avoid repeating the shared attributes on both types. Using the same example from #4, what I would hope is for:

struct Attr {
   #[attribute(flatten)]
   shared: SharedAttributes
}

struct SharedAttributes {
    shared_key: String
}

Should parse

#[attr(shared_key = "hi")]
@ModProg
Copy link
Owner

ModProg commented Apr 12, 2023

Yeah that sounds like a reasonable request. Initial idea would be that the AttributeParser gets a parse_one function, that parses one key(= value)? pair.

So in the attribute parsing step every field could do one parse. Designed right this could open the door for more advanced parsing e.g. nested structs as well.

@ecton
Copy link
Author

ecton commented Apr 12, 2023

I want to point out that while I still think it's a neat request, I've decided to keep the derive's using separate attributes for now -- it just felt a little weird thinking about how you'd split the implementations if you didn't want to ship the ViewSchema to the client, since it's primarily a server/local trait despite being defined in core.

So this feature isn't actually something I'd be using currently.

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

2 participants