| Crates.io | conditional-mod |
| lib.rs | conditional-mod |
| version | 0.1.0 |
| created_at | 2025-03-18 17:01:32.89921+00 |
| updated_at | 2025-03-18 17:01:32.89921+00 |
| description | Simple rust macro for conditional module visibility |
| homepage | https://github.com/apfitzge/conditional-mod |
| repository | https://github.com/apfitzge/conditional-mod |
| max_upload_size | |
| id | 1596877 |
| size | 14,418 |
Provides a simple macro conditional_vis_mod to change module visibility based on a condition.
Assume there is some module file my_module.rs.
The visibility of the module can be changed based on conditions, such as compiler features:
// This will declare the module as public if "my_feature" is active, and private otherwise.
conditional_mod::conditional_vis_mod!(my_module, feature = "my_feature", pub);
// This will declare the module as public if "my_feature" is not active, and `pub(crate)` otherwise.
conditional_mod::conditional_vis_mod!(my_module, feature = "my_feature", pub, pub(crate));