#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

#583 in Rust patterns

Download history 40518/week @ 2024-11-15 34584/week @ 2024-11-22 36930/week @ 2024-11-29 39226/week @ 2024-12-06 34429/week @ 2024-12-13 20542/week @ 2024-12-20 17663/week @ 2024-12-27 35538/week @ 2025-01-03 37840/week @ 2025-01-10 36157/week @ 2025-01-17 38291/week @ 2025-01-24 43793/week @ 2025-01-31 49052/week @ 2025-02-07 40671/week @ 2025-02-14 47955/week @ 2025-02-21 39817/week @ 2025-02-28

184,559 downloads per month
Used in 199 crates (21 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–640KB
~15K SLoC