{"id":34250086,"url":"https://github.com/alephcubed/loose_enum","last_synced_at":"2026-03-12T11:03:18.822Z","repository":{"id":328916471,"uuid":"1111869396","full_name":"AlephCubed/loose_enum","owner":"AlephCubed","description":"A macro for defining loose repr enums.","archived":false,"fork":false,"pushed_at":"2025-12-16T19:41:45.000Z","size":38,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-19T18:55:30.551Z","etag":null,"topics":["macro","macros","repr","representation","rust","utility"],"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/AlephCubed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-07T19:33:06.000Z","updated_at":"2025-12-16T19:40:25.000Z","dependencies_parsed_at":"2025-12-20T00:00:08.922Z","dependency_job_id":null,"html_url":"https://github.com/AlephCubed/loose_enum","commit_stats":null,"previous_names":["alephcubed/loose_enum"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AlephCubed/loose_enum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlephCubed%2Floose_enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlephCubed%2Floose_enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlephCubed%2Floose_enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlephCubed%2Floose_enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlephCubed","download_url":"https://codeload.github.com/AlephCubed/loose_enum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlephCubed%2Floose_enum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30422854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T09:20:56.688Z","status":"ssl_error","status_checked_at":"2026-03-12T09:20:13.792Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["macro","macros","repr","representation","rust","utility"],"created_at":"2025-12-16T09:10:59.215Z","updated_at":"2026-03-12T11:03:18.813Z","avatar_url":"https://github.com/AlephCubed.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loose Enum\n[![Version](https://img.shields.io/crates/v/loose_enum)](https://crates.io/crates/loose_enum)\n[![Docs](https://img.shields.io/docsrs/loose_enum)](https://docs.rs/loose_enum)\n![License](https://img.shields.io/crates/l/loose_enum)\n\nA macro for defining loose repr enums.\n\nWhen parsing userdata, you often have known/supported cases; however, users don't always follow the rules.\nOne way to solve this is having a backup `Undefined` case that supports any value. This crate hopes to simplify this process.\n\n### Example:\nAn integer repr bool, with 0 being false and 1 being true would look something like this:\n```rust\nloose_enum::loose_enum! {\n    #[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash)]\n    pub enum LooseBool: i32 {\n        #[default]\n        False = 0,\n        True = 1,\n    }\n}\n```\nWhich expands into this type:\n```rust\n#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash)]\npub enum LooseBool {\n    #[default]\n    False,\n    True,\n    /// Any value that doesn't match another case. \n    Undefined(i32),\n}\n```\nThe macro will also generate `From\u003ci32\u003e` and `Into\u003ci32\u003e` trait implementations.\nIf the `serde` feature is enabled, `Serialize` and `Deserialize` will also be implemented.\n## Special Cases\n### String\nA special case has been created for when `String` is the data type, which will implement `From\u003c\u0026str\u003e` on top of the normal trait implementations.\n### Generics\nThere is also **experimental** support for generic types.\n```rust\nuse num_traits::{ConstZero, ConstOne};\n\nloose_enum::loose_enum! {\n    #[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash)]\n    pub enum LooseBool\u003cT: PartialEq + ConstZero + ConstOne\u003e {\n        #[default]\n        False = T::ZERO,\n        True = T::ONE,\n    }\n}\n```\nDue to the orphan rule, `Into\u003cT\u003e` cannot be implemented. Instead, an `into_repr` method will be added.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falephcubed%2Floose_enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falephcubed%2Floose_enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falephcubed%2Floose_enum/lists"}