easy-ext icon indicating copy to clipboard operation
easy-ext copied to clipboard

Support trait-only and impl-only attributes

Open mbazero opened this issue 1 year ago • 3 comments

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) {}
}

mbazero avatar May 31 '24 08:05 mbazero

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

Veetaha avatar May 31 '24 10:05 Veetaha

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 avatar May 31 '24 21:05 mbazero

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.

mbazero avatar May 31 '24 23:05 mbazero