#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

#1086 in Rust patterns

Download history 3776/week @ 2024-01-29 2939/week @ 2024-02-05 3027/week @ 2024-02-12 3148/week @ 2024-02-19 3188/week @ 2024-02-26 5053/week @ 2024-03-04 3476/week @ 2024-03-11 4048/week @ 2024-03-18 4848/week @ 2024-03-25 4852/week @ 2024-04-01 5341/week @ 2024-04-08 4408/week @ 2024-04-15 4345/week @ 2024-04-22 4386/week @ 2024-04-29 3840/week @ 2024-05-06 4244/week @ 2024-05-13

17,174 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

~285–740KB
~18K SLoC