Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
subscriber: use macros for module declarations (#1009)
## Motivation This is code refactoring. Currently, there is a lot of code that declares modules as follows: ```rust #[cfg(feature = "registry")] #[cfg_attr(docsrs, doc(cfg(feature = "registry")))] pub use registry::Registry; #[cfg(feature = "registry")] #[cfg_attr(docsrs, doc(cfg(feature = "registry")))] pub fn registry() -> Registry { Registry::default() } ``` It is verbose to write a module declaration multiple times using the feature attribute. Also, if the definition for the same feature spans multiple places, it will be a little harder to read the code. ## Solution You can combine features attributes in one place by writing as follows. It also eliminates the need to write the same code over and over again. ```rust cfg_feature!("registry", { pub use registry::Registry; pub fn registry() -> Registry { Registry::default() } }); ``` If this code is accepted, we will extend the declaration of the module using macros to other files as well as `tracing-subscriber/lib.rs`.
- Loading branch information