#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

#1607 in Rust patterns

Download history 4843/week @ 2024-03-24 4732/week @ 2024-03-31 5508/week @ 2024-04-07 4264/week @ 2024-04-14 4404/week @ 2024-04-21 4339/week @ 2024-04-28 3774/week @ 2024-05-05 4655/week @ 2024-05-12 4369/week @ 2024-05-19 4600/week @ 2024-05-26 5322/week @ 2024-06-02 8353/week @ 2024-06-09 10025/week @ 2024-06-16 10630/week @ 2024-06-23 91748/week @ 2024-06-30 90859/week @ 2024-07-07

204,116 downloads per month
Used in 69 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

~270–720KB
~17K SLoC