#conditional-compilation #override #conditional #pub #compilation

macro visibility

Attribute to override the visibility of items (useful in conjunction with cfg_attr)

5 releases

0.1.1 Aug 13, 2024
0.1.0 Sep 2, 2023
0.0.1 Mar 6, 2021
0.0.0 Mar 6, 2021

#574 in Rust patterns

Download history 72087/week @ 2024-10-24 37186/week @ 2024-10-31 38020/week @ 2024-11-07 40535/week @ 2024-11-14 37467/week @ 2024-11-21 34537/week @ 2024-11-28 39354/week @ 2024-12-05 34711/week @ 2024-12-12 24797/week @ 2024-12-19 16202/week @ 2024-12-26 32235/week @ 2025-01-02 37554/week @ 2025-01-09 36430/week @ 2025-01-16 37563/week @ 2025-01-23 44436/week @ 2025-01-30 47770/week @ 2025-02-06

174,058 downloads per month
Used in 188 crates (19 directly)

Zlib OR MIT OR Apache-2.0

9KB

#[visibility::make]

Repository Latest version Documentation MSRV unsafe forbidden License CI

Attribute to override the visibility of items (especially useful in conjunction with #[cfg_attr()]).

Since it is currently not possible to conditionally modify the visibility of an item, but since it is possible to conditionally apply an attribute, this crate features a trivial attribute that modifies the visibility of the decorated item. This way, by conditionally applying it, one can achieve the desired goal:

Example

/// Some fancy docs.
///
/// ## Example
///
/// ```rust
/// ::my_crate::module::foo();
/// ```
// Assuming `cargo test --doc --features integration-tests` is run:
#[cfg_attr(feature = "integration-tests", visibility::make(pub))]
mod module {
    pub fn foo() {}
}

Dependencies

~210–650KB
~15K SLoC