Crates.io | conditional-mod |
lib.rs | conditional-mod |
version | |
source | src |
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 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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));