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

Parse attributes without prefix #8

Open
kangalio opened this issue Mar 6, 2022 · 0 comments
Open

Parse attributes without prefix #8

kangalio opened this issue Mar 6, 2022 · 0 comments

Comments

@kangalio
Copy link

kangalio commented Mar 6, 2022

I'm trying bae as an alternative to darling. With darling, I implemented prefix-less attributes for my library:

#[derive(Modal)] // My derive macro
#[name = "Modal title"]
struct MyModal {
    #[name = "First input label"]
    #[placeholder = "Your first input goes here"]
    #[min_length = 5]
    #[min_length = 500]
    first_input: String,
    #[name = "Second input label"]
    #[paragraph]
    second_input: Option<String>,
}

However, bae seems to require all attributes to be enclosed in a common identifier (the FromAttributes-derived struct name):

#[derive(bae::FromAttributes)]
struct Poise { /* ... */ }

#[poise(name = "Modal title")]
struct MyModal {
    #[poise(name = "First input label")]
    #[poise(placeholder = "Your first input goes here")]
    #[poise(min_length = 5)]
    #[poise(min_length = 500)]
    first_input: String,
    #[poise(name = "Second input label")]
    #[poise(paragraph)]
    second_input: Option<String>,
}

Implemented here:

bae/src/lib.rs

Line 167 in 3b018d1

Some(ident) if ident == #attr_name => {

Would a PR be accepted to add support for the first snippet's syntax? For example with a #[no_prefix] attribute on the FromAttributes-derived struct

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