danielhenrymantilla / macro_rules_attribute-rs

Use declarative macros as proc_macro attributes or derives
https://docs.rs/macro-rules-attribute
Apache License 2.0
102 stars 10 forks source link

Feature Request: Option to make generated definitions public unconditionally #22

Open dima-starosud opened 10 months ago

dima-starosud commented 10 months ago

Feature Request

Summary

I would like to request a feature for the macro_rules_attribute::attribute_alias where the engineer can choose the visibility of generated definitions (specifically to make them pub unconditionally, not just pub(in crate)).

Motivation

Currently, the definitions are generated with pub(in crate) visibility, which limits their accessibility to the current crate only. There are cases where wider accessibility is necessary, for example when the generated code must be accessible from other crates.

In my use of the attribute_alias crate, I've encountered situations where I need the macro-generated definitions to be used in most of my crates within the workspace, i.e. I would like to define an alias in a common crate and import it in other crates.

Proposed Solution

  1. Introduce an option (possibly through a cfg feature) that lets users specify the desired visibility of the generated items.
  2. Another option is to generate aliases to be simply pub and let the engineer to decide whether he wants to export them or not.

Alternatives Considered

Without such a feature, engineer has to copy-paste the definition of an alias in each crate he wants to use it.

Thank you for considering this feature request. I believe it would be a valuable addition for many users of the crate.