Attribute Macro visibility::make

source ·
#[make]
Expand description

Overrides the visibility of the annotated item with the one given to this attribute:

§Example

mod module {
    #[visibility::make(pub)]
    fn foo () {}
}

module::foo();

§To be used in conjunction with #[cfg_attr]

That’s where this attribute really shines: it is not possible to conditionally modify the visibility of an item, but it is possible to conditionally apply an attribute. If the attribute then modifies the visibility of the decorated item, we have achieved our goal:

mod module {
    #[cfg_attr(all(/* feature = "integration-tests" */),
        visibility::make(pub),
    )]
    fn foo () {}
}

module::foo();