Skip to content

Comments

Support trait-only and impl-only attributes#43

Open
mbazero wants to merge 1 commit intotaiki-e:mainfrom
mbazero:main
Open

Support trait-only and impl-only attributes#43
mbazero wants to merge 1 commit intotaiki-e:mainfrom
mbazero:main

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