#conditional-compilation #visibility #override #pub #attributes #item

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

#965 in Rust patterns

Download history 47955/week @ 2025-02-21 48100/week @ 2025-02-28 50629/week @ 2025-03-07 56266/week @ 2025-03-14 52734/week @ 2025-03-21 63068/week @ 2025-03-28 66513/week @ 2025-04-04 90652/week @ 2025-04-11 58712/week @ 2025-04-18 66047/week @ 2025-04-25 66666/week @ 2025-05-02 69614/week @ 2025-05-09 81358/week @ 2025-05-16 60103/week @ 2025-05-23 66075/week @ 2025-05-30 52549/week @ 2025-06-06

272,870 downloads per month
Used in 213 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

~165–580KB
~14K SLoC