#macro #cfg

macro cfg-vis

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

4 releases (2 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

#451 in Procedural macros

Download history 392/week @ 2023-01-27 540/week @ 2023-02-03 599/week @ 2023-02-10 385/week @ 2023-02-17 302/week @ 2023-02-24 227/week @ 2023-03-03 210/week @ 2023-03-10 499/week @ 2023-03-17 361/week @ 2023-03-24 351/week @ 2023-03-31 392/week @ 2023-04-07 348/week @ 2023-04-14 198/week @ 2023-04-21 31/week @ 2023-04-28 244/week @ 2023-05-05 207/week @ 2023-05-12

731 downloads per month

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

~3MB
~61K SLoC