Skip to content

Support trait-only and impl-only attributes #43

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mbazero
Copy link
Contributor

@mbazero mbazero commented May 31, 2024

Resolve issue #41 by introducing #[ext_attr(trait_only)] and #[ext_attr(impl_only)] attributes to specify trait-only and impl-only attributes respectively.

#[ext(TraitOnlyExample)]
#[ext_attr(trait_only)]
#[my_trait_only_attr]
impl String {
    fn foo(&self) {}
}

#[ext(ImplOnlyExample)]
impl String {
    #[ext_attr(impl_only)]
    #[my_impl_only_attr]
    fn foo(&self) {}
}

@Veetaha
Copy link

Veetaha commented May 31, 2024

One thing. Maybe the impl_attr/trait_attr can be wrapped in #[ext(impl_attr/trait_attr)] to make it obvious which macro they come from

@mbazero
Copy link
Contributor Author

mbazero commented May 31, 2024

One thing. Maybe the impl_attr/trait_attr can be wrapped in #[ext(impl_attr/trait_attr)] to make it obvious which macro they come from

Good point. I looked around and your naming style indeed seems more idomatic--see serde attributes for example.

Will make the change.

@mbazero
Copy link
Contributor Author

mbazero commented May 31, 2024

One thing. Maybe the impl_attr/trait_attr can be wrapped in #[ext(impl_attr/trait_attr)] to make it obvious which macro they come from

Good point. I looked around and your naming style indeed seems more idomatic--see serde attributes for example.

Will make the change.

Updated. But instead of #[ext(impl_attr/trait_attr)] I went with #[ext_attr(impl_only/trait_only)] to clearly distinguish between main #[ext] attribute.

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

Successfully merging this pull request may close these issues.

2 participants