{"id":16687890,"url":"https://github.com/omid/mutually_exclusive_features","last_synced_at":"2025-04-10T00:32:48.585Z","repository":{"id":206375749,"uuid":"716512937","full_name":"omid/mutually_exclusive_features","owner":"omid","description":"Some macros to check mutually exclusive conditions of features in Rust","archived":false,"fork":false,"pushed_at":"2024-02-05T14:07:10.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T02:14:04.901Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-11-09T09:47:26.000Z","updated_at":"2025-03-13T12:35:25.000Z","dependencies_parsed_at":"2024-02-05T15:40:52.606Z","dependency_job_id":null,"html_url":"https://github.com/omid/mutually_exclusive_features","commit_stats":null,"previous_names":["omid/mutually_exclusive_features"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omid%2Fmutually_exclusive_features","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omid%2Fmutually_exclusive_features/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omid%2Fmutually_exclusive_features/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omid%2Fmutually_exclusive_features/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omid","download_url":"https://codeload.github.com/omid/mutually_exclusive_features/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248135798,"owners_count":21053764,"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-12T15:25:38.724Z","updated_at":"2025-04-10T00:32:48.555Z","avatar_url":"https://github.com/omid.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mutually Exclusive Features \n\n[![crates.io](https://img.shields.io/crates/v/mutually_exclusive_features.svg)](https://crates.io/crates/mutually_exclusive_features)\n[![Build Status](https://github.com/omid/mutually_exclusive_features/actions/workflows/test.yml/badge.svg)](https://github.com/omid/mutually_exclusive_features/actions/workflows/test.yml)\n[![docs](https://docs.rs/mutually_exclusive_features/badge.svg)](https://docs.rs/mutually_exclusive_features)\n\n### Macros to check mutually exclusive `features` in Rust\n___\n\nIt contains `none_or_one_of` and `exactly_one_of` macros.\n\nBoth check mutually exclusive features in Rust,\nbut `none_or_one_of` allows for no features to be enabled,\nwhile `exactly_one_of` requires exactly one feature to be enabled.\n\n## Usage\n\n---\n\n### none_or_one_of\n\n---\n\nCall it with the list of features you want to be mutually exclusive:\n```rust\nuse mutually_exclusive_features::none_or_one_of;\nnone_or_one_of!(\"feature1\", \"feature2\", \"feature3\");\n```\n\nWhich will generate the following code:\n```rust\n#[cfg(all(feature=\"feature1\", feature=\"feature2\"))]\ncompile_error!(\"The `feature1` and `feature2` features are mutually exclusive and cannot be enabled at the same time!\");\n\n#[cfg(all(feature=\"feature1\", feature=\"feature3\"))]\ncompile_error!(\"The `feature1` and `feature3` features are mutually exclusive and cannot be enabled at the same time!\");\n\n#[cfg(all(feature=\"feature2\", feature=\"feature3\"))]\ncompile_error!(\"The `feature2` and `feature3` features are mutually exclusive and cannot be enabled at the same time!\");\n```\n\n### exactly_one_of\n\n---\n\nIt's the same, but requires exactly one feature to be enabled:\n```rust\nuse mutually_exclusive_features::exactly_one_of;\nexactly_one_of!(\"feature1\", \"feature2\", \"feature3\");\n```\n\nWhich will generate the following code:\n```rust\n#[cfg(all(feature=\"feature1\", feature=\"feature2\"))]\ncompile_error!(\"The `feature1` and `feature2` features are mutually exclusive and cannot be enabled at the same time!\");\n\n#[cfg(all(feature=\"feature1\", feature=\"feature3\"))]\ncompile_error!(\"The `feature1` and `feature3` features are mutually exclusive and cannot be enabled at the same time!\");\n\n#[cfg(all(feature=\"feature2\", feature=\"feature3\"))]\ncompile_error!(\"The `feature2` and `feature3` features are mutually exclusive and cannot be enabled at the same time!\");\n\n#[cfg(not(any(feature=\"feature1\", feature=\"feature2\", feature=\"feature3\")))]\ncompile_error!(\"You must enable exactly one of `feature1`, `feature2`, `feature3` features!\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomid%2Fmutually_exclusive_features","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomid%2Fmutually_exclusive_features","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomid%2Fmutually_exclusive_features/lists"}