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

#[inspectable(inner_attributes)] requires funky undocumented syntax #91

Open
Xion opened this issue Oct 12, 2022 · 0 comments
Open

#[inspectable(inner_attributes)] requires funky undocumented syntax #91

Xion opened this issue Oct 12, 2022 · 0 comments

Comments

@Xion
Copy link

Xion commented Oct 12, 2022

For InNewWindow<T> struct fields, the corresponding WindowAttributes declare an inner_attributes value that can be set to the attributes of T. However, there is no example for doing this when deriving Inspectable through the proc-macro (#[derive(Inspectable)]) which is an issue because it doesn't follow the conventional syntax.

Typically (c.f. popular crates like serde), when #[foo] attributes support nested values, they do so using a function-like syntax, e.g.:

#[serde(rename(serialize = "ser_name"))]

One would expect #[inspectable] to do likewise:

    #[inspectable(
        label = "Player",
        title = "Player", title_bar, resizable, scrollable,
        inner_attributes(despawnable = false),
    )]
    player: InNewWindow<InspectorQuerySingle<Entity, With<Player>>>,

Unfortunately, that's not supported. I did some digging into the proc-macro code for the attribute and found that the way to make it work is to explicitly create the value for inner_attributes and assign to it:

#[inspectable(/* ... */ inner_attributes = EntityAttributes{despawnable: false})]

This is quite unusual; normally, users don't have to explicitly provide values of the crate's own types when using a #[derive] macro.

I'd suggest providing an example of this atypical use of inner_attributes. or changing it to follow de-facto conventions of the Rust ecosystem.

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