{"id":13595252,"url":"https://github.com/dtolnay/efg","last_synced_at":"2025-04-09T10:33:19.073Z","repository":{"id":37479859,"uuid":"435248619","full_name":"dtolnay/efg","owner":"dtolnay","description":"Conditional compilation using boolean expression syntax, rather than any(), all(), not()","archived":true,"fork":false,"pushed_at":"2022-12-18T20:47:04.000Z","size":94,"stargazers_count":295,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-09T09:38:25.208Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtolnay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"dtolnay"}},"created_at":"2021-12-05T18:38:04.000Z","updated_at":"2024-01-04T17:03:51.000Z","dependencies_parsed_at":"2023-01-29T19:50:12.049Z","dependency_job_id":null,"html_url":"https://github.com/dtolnay/efg","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fefg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fefg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fefg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Fefg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtolnay","download_url":"https://codeload.github.com/dtolnay/efg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248020593,"owners_count":21034459,"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-08-01T16:01:46.413Z","updated_at":"2025-04-09T10:33:14.064Z","avatar_url":"https://github.com/dtolnay.png","language":"Rust","funding_links":["https://github.com/sponsors/dtolnay"],"categories":["Rust"],"sub_categories":[],"readme":"Conditional compilation expressions\n===================================\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/efg-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/efg)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/efg.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/efg)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-efg-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/efg)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/efg/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/efg/actions?query=branch%3Amaster)\n\nConditional compilation using boolean expression syntax, rather than *any()*,\n*all()*, *not()*.\n\n```toml\n[dependencies]\nefg = \"0.1\"\n```\n\n\u003cbr\u003e\n\n## Summary\n\nRust's `cfg` and `cfg_attr` conditional compilation attributes use a restrictive\ndomain-specific language for specifying configuration predicates. The syntax is\ndescribed in the *[Conditional compilation]* page of the Rust reference. The\nreason for this syntax as opposed to ordinary boolean expressions was to\naccommodate restrictions that old versions of rustc used to have on the grammar\nof attributes.\n\nHowever, all restrictions on the attribute grammar were lifted in Rust 1.18.0 by\n[rust-lang/rust#40346]. This crate explores implementing conditional compilation\nusing ordinary boolean expressions\ninstead:\u0026ensp;`\u0026\u0026`,\u0026ensp;`||`,\u0026ensp;`!`\u0026ensp;as usual in Rust syntax.\n\n[Conditional compilation]: https://doc.rust-lang.org/1.57.0/reference/conditional-compilation.html\n[rust-lang/rust#40346]: https://github.com/rust-lang/rust/pull/40346\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003e\u003ccenter\u003ebuilt into rustc\u003c/center\u003e\u003c/th\u003e\u003cth\u003e\u003ccenter\u003ethis crate\u003c/center\u003e\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e#[cfg(any(\u003ci\u003ething1\u003c/i\u003e, \u003ci\u003ething2\u003c/i\u003e, \u0026hellip;))]\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e#[efg(\u003ci\u003ething1\u003c/i\u003e || \u003ci\u003ething2\u003c/i\u003e || \u0026hellip;)]\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e#[cfg(all(\u003ci\u003ething1\u003c/i\u003e, \u003ci\u003ething2\u003c/i\u003e, \u0026hellip;))]\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e#[efg(\u003ci\u003ething1\u003c/i\u003e \u0026amp;\u0026amp; \u003ci\u003ething2\u003c/i\u003e \u0026amp;\u0026amp; \u0026hellip;)]\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ccode\u003e#[cfg(not(\u003ci\u003ething\u003c/i\u003e))]\u003c/code\u003e\u003c/td\u003e\u003ctd\u003e\u003ccode\u003e#[efg(!\u003ci\u003ething\u003c/i\u003e)]\u003c/code\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cbr\u003e\n\n## Examples\n\nA real-world example from the `quote` crate:\n\n```rust\n#[efg(feature \"proc-macro\" \u0026\u0026 !(target_arch \"wasm32\" \u0026\u0026 target_os \"unknown\"))]\nextern crate proc_macro;\n```\n\nand from the `proc-macro2` crate:\n\n```rust\n#[efg(super_unstable || feature \"span-locations\")]\npub fn start(\u0026self) -\u003e LineColumn {\n```\n\n\u003cbr\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fefg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtolnay%2Fefg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Fefg/lists"}