#cfg #macro #visibility #pub #target #linux #vis

macro cfg-vis

A macro to support #[cfg()] on visibility

3 releases (breaking)

0.3.0 Feb 11, 2023
0.2.2 Feb 11, 2023
0.2.1 Jan 24, 2023
0.2.0 Jan 23, 2023
0.1.0 Jan 11, 2023

#433 in Procedural macros

Download history 1316/week @ 2023-12-10 877/week @ 2023-12-17 634/week @ 2023-12-24 1632/week @ 2023-12-31 1507/week @ 2024-01-07 1637/week @ 2024-01-14 1813/week @ 2024-01-21 2287/week @ 2024-01-28 1972/week @ 2024-02-04 1167/week @ 2024-02-11 1635/week @ 2024-02-18 2086/week @ 2024-02-25 2426/week @ 2024-03-03 1866/week @ 2024-03-10 2859/week @ 2024-03-17 2010/week @ 2024-03-24

9,244 downloads per month
Used in 6 crates (2 directly)

MIT license

16KB
344 lines

cfg-vis

A macro to support #[cfg()] on visibility.

use cfg_vis::{cfg_vis, cfg_vis_fields};

// default visibility is `pub`, while the target is linux, the visibility is `pub(crate)`.
#[cfg_vis(target_os = "linux", pub(crate))]
pub fn foo() {}

#[cfg_vis_fields]
pub struct Foo {
    #[cfg_vis(test, pub)]
    pub_in_test: i32,
    #[cfg_vis(test)]
    pub prv_in_test: i32,
}

Dependencies

~3.5MB
~72K SLoC