danielhenrymantilla/visibility.rs

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

Rust

20

19 commits

updated May 31, 2026

See the code

README

#[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() {}
}

danielhenrymantilla/visibility.rs

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

Rust

20

19 commits

updated May 31, 2026

See the code

README

#[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() {}
}

Project health

Overall

3.2/10

Maintained

0/10

Code review

1/10
OpenSSF Scorecard

Significant stargazers

Rüdiger Klaehn

210 followers · starred Sep 2022

8573

13 followers · starred Oct 2023