#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

#445 in Rust patterns

Download history 94712/week @ 2024-07-24 114369/week @ 2024-07-31 97176/week @ 2024-08-07 82457/week @ 2024-08-14 74058/week @ 2024-08-21 59582/week @ 2024-08-28 69367/week @ 2024-09-04 62027/week @ 2024-09-11 216352/week @ 2024-09-18 225383/week @ 2024-09-25 561557/week @ 2024-10-02 591043/week @ 2024-10-09 535703/week @ 2024-10-16 73469/week @ 2024-10-23 38112/week @ 2024-10-30 29524/week @ 2024-11-06

691,769 downloads per month
Used in 158 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

~235–680KB
~16K SLoC