{"id":18016887,"url":"https://github.com/fitzgen/derive_is_enum_variant","last_synced_at":"2025-03-26T18:32:30.981Z","repository":{"id":55500219,"uuid":"103583174","full_name":"fitzgen/derive_is_enum_variant","owner":"fitzgen","description":"Automatically derives `is_dog` and `is_cat` methods for `enum Pet { Dog, Cat }`.","archived":false,"fork":false,"pushed_at":"2020-12-26T14:28:17.000Z","size":11,"stargazers_count":23,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T11:59:40.643Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-14T21:24:53.000Z","updated_at":"2024-09-05T03:42:48.000Z","dependencies_parsed_at":"2022-08-15T01:50:45.371Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/derive_is_enum_variant","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fderive_is_enum_variant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fderive_is_enum_variant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fderive_is_enum_variant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Fderive_is_enum_variant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/derive_is_enum_variant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245713133,"owners_count":20660348,"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-30T04:19:36.994Z","updated_at":"2025-03-26T18:32:30.730Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# derive_is_enum_variant\n\n## `derive_is_enum_variant`\n\n[![](https://docs.rs/derive_is_enum_variant/badge.svg)](https://docs.rs/derive_is_enum_variant/) [![](http://meritbadge.herokuapp.com/derive_is_enum_variant) ![](https://img.shields.io/crates/d/derive_is_enum_variant.png)](https://crates.io/crates/derive_is_enum_variant) [![Build Status](https://travis-ci.org/fitzgen/derive_is_enum_variant.png?branch=master)](https://travis-ci.org/fitzgen/derive_is_enum_variant)\n\nStop writing `pub is_whatever(\u0026self) -\u003e bool` for your `enum`s by hand -- it's a\npain! Just `#[derive(is_enum_variant)]` instead!\n\n### Usage\n\nAdd `derive_is_enum_variant` to your crate's `Cargo.toml`:\n\n```toml\n[dependencies]\nderive_is_enum_variant = \"\u003cinsert-latest-version-here\u003e\"\n```\n\nAnd then add `#[derive(is_enum_variant)]` to your `enum` definitions:\n\n```rust\n#[macro_use]\nextern crate derive_is_enum_variant;\n\n#[derive(is_enum_variant)]\npub enum Pet {\n    Doggo,\n    Kitteh,\n}\n\nfn main() {\n    let pet = Pet::Doggo;\n\n    assert!(pet.is_doggo());\n    assert!(!pet.is_kitteh());\n}\n```\n\n#### Customizing Predicate Names\n\nBy default, the predicates are named `is_snake_case_of_variant_name`. You can\nuse any name you want instead with `#[is_enum_variant(name = \"..\")]`:\n\n```rust\n\n#[derive(is_enum_variant)]\npub enum Pet {\n    #[is_enum_variant(name = \"is_real_good_boy\")]\n    Doggo,\n    Kitteh,\n}\n\nlet pet = Pet::Doggo;\nassert!(pet.is_real_good_boy());\n```\n\n#### Skipping Predicates for Certain Variants\n\nIf you don't want to generate a predicate for a certain variant, you can use\n`#[is_enum_variant(skip)]`:\n\n```rust\n\n#[derive(is_enum_variant)]\npub enum Errors {\n    Io(::std::io::Error),\n\n    #[doc(hidden)]\n    #[is_enum_variant(skip)]\n    __NonExhaustive,\n}\n\n```\n\n### License\n\nLicensed under either of\n\n  * Apache License, Version 2.0 ([`LICENSE-APACHE`](./LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n  * MIT license ([`LICENSE-MIT`](./LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for hacking!\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n\nLicense: Apache-2.0/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fderive_is_enum_variant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Fderive_is_enum_variant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Fderive_is_enum_variant/lists"}