#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

#648 in Rust patterns

Download history 63133/week @ 2024-09-14 217968/week @ 2024-09-21 228856/week @ 2024-09-28 645587/week @ 2024-10-05 516625/week @ 2024-10-12 518074/week @ 2024-10-19 61839/week @ 2024-10-26 37853/week @ 2024-11-02 40267/week @ 2024-11-09 39910/week @ 2024-11-16 32970/week @ 2024-11-23 38623/week @ 2024-11-30 38807/week @ 2024-12-07 35264/week @ 2024-12-14 16538/week @ 2024-12-21 15021/week @ 2024-12-28

111,945 downloads per month
Used in 179 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

~230–680KB
~16K SLoC