#visibility #mod #conditional-mod

conditional-mod

Simple rust macro for conditional module visibility

1 unstable release

0.1.0 Mar 18, 2025

#452 in Development tools

Download history 30/week @ 2025-03-13 9242/week @ 2025-03-20 8503/week @ 2025-03-27 8949/week @ 2025-04-03 9576/week @ 2025-04-10

36,333 downloads per month

Custom license

6KB

conditional-mod

Provides a simple macro conditional_vis_mod to change module visibility based on a condition.

Usage

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));

No runtime deps