conditional-mod

Crates.ioconditional-mod
lib.rsconditional-mod
version0.1.0
created_at2025-03-18 17:01:32.89921+00
updated_at2025-03-18 17:01:32.89921+00
descriptionSimple rust macro for conditional module visibility
homepagehttps://github.com/apfitzge/conditional-mod
repositoryhttps://github.com/apfitzge/conditional-mod
max_upload_size
id1596877
size14,418
Andrew Fitzgerald (apfitzge)

documentation

README

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));
Commit count: 8

cargo fmt