visibility

Crates.iovisibility
lib.rsvisibility
version0.1.1
sourcesrc
created_at2021-03-06 20:13:01.291206
updated_at2024-08-13 12:40:03.774625
descriptionAttribute to override the visibility of items (useful in conjunction with cfg_attr)
homepagehttps://crates.io/crates/visibility
repositoryhttps://github.com/danielhenrymantilla/visibility.rs
max_upload_size
id364924
size23,505
Daniel Henry-Mantilla (danielhenrymantilla)

documentation

https://docs.rs/visibility

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() {}
}
Commit count: 15

cargo fmt