{"id":16851919,"url":"https://github.com/cad97/cfg-pub","last_synced_at":"2025-06-11T18:33:38.769Z","repository":{"id":90989578,"uuid":"284804435","full_name":"CAD97/cfg-pub","owner":"CAD97","description":null,"archived":false,"fork":false,"pushed_at":"2020-08-03T20:50:37.000Z","size":599,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T16:10:56.745Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CAD97.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-03T20:50:16.000Z","updated_at":"2020-08-03T20:50:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"9331c7de-b996-4bb0-ae69-ffdcd43f0db9","html_url":"https://github.com/CAD97/cfg-pub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAD97%2Fcfg-pub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAD97%2Fcfg-pub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAD97%2Fcfg-pub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CAD97%2Fcfg-pub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CAD97","download_url":"https://codeload.github.com/CAD97/cfg-pub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244196786,"owners_count":20414371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T13:34:07.531Z","updated_at":"2025-03-18T09:40:20.562Z","avatar_url":"https://github.com/CAD97.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proof-of-concept macro for `#[cfg]` gating visibility\n\nDisclaimer: while the syntax is an if-else-if-else chain,\nthe macro does not actually implement `else` semantics (yet).\nThus you need to do that manually. Adding that should not be\ntoo difficult, and should be done before publishing.\n\nI (@CAD97) am not really invested enough to actually do that.\nI'd be willing to help someone else do that, though.\n(Perhaps you can just reuse [`cfg_if!`](https://crates.io/crates/cfg-if)?)\n\n## Example\n\nThis is [cfg-pub/examples/example.rs](cfg-pub/examples/example.rs).\n\n```rust\nuse cfg_pub::cfg_pub;\n\n#[cfg_pub(\n    if #[cfg(SET_CFG)] pub\n    else if #[cfg(not(SET_CFG))] pub(self)\n)]\nfn main() {\n    println!(\"do something\");\n}\n```\n\n```powershell\nPS\u003e $env:RUSTFLAGS=$null\nPS\u003e cargo expand --example example\n```\n\n```rust\n#![feature(prelude_import)]\n#[prelude_import]\nuse std::prelude::v1::*;\n#[macro_use]\nextern crate std;\nuse cfg_pub::cfg_pub;\n#[cfg(not(SET_CFG))]\npub(self) fn main() {\n    {\n        ::std::io::_print(::core::fmt::Arguments::new_v1(\n            \u0026[\"do something\\n\"],\n            \u0026match () {\n                () =\u003e [],\n            },\n        ));\n    };\n}\n```\n\n```powershell\nPS\u003e $env:RUSTFLAGS=\"--cfg SET_CFG\"\nPS\u003e cargo expand --example example\n```\n\n```rust\n#![feature(prelude_import)]\n#[prelude_import]\nuse std::prelude::v1::*;\n#[macro_use]\nextern crate std;\nuse cfg_pub::cfg_pub;\n#[cfg(SET_CFG)]\npub fn main() {\n    {\n        ::std::io::_print(::core::fmt::Arguments::new_v1(\n            \u0026[\"do something\\n\"],\n            \u0026match () {\n                () =\u003e [],\n            },\n        ));\n    };\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcad97%2Fcfg-pub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcad97%2Fcfg-pub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcad97%2Fcfg-pub/lists"}