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

macro visibility

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

4 releases

0.1.0 Sep 2, 2023
0.0.1 Mar 6, 2021
0.0.0 Mar 6, 2021

#1032 in Rust patterns

Download history 3599/week @ 2024-01-24 3890/week @ 2024-01-31 2891/week @ 2024-02-07 2946/week @ 2024-02-14 3178/week @ 2024-02-21 4541/week @ 2024-02-28 3896/week @ 2024-03-06 3745/week @ 2024-03-13 4562/week @ 2024-03-20 4448/week @ 2024-03-27 5031/week @ 2024-04-03 5302/week @ 2024-04-10 4405/week @ 2024-04-17 4525/week @ 2024-04-24 3929/week @ 2024-05-01 2881/week @ 2024-05-08

16,565 downloads per month
Used in 51 crates (15 directly)

Zlib OR MIT OR Apache-2.0

7KB

#[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

~300–750KB
~18K SLoC