{"id":16088009,"url":"https://github.com/prostomarkeloff/enum-to-types","last_synced_at":"2025-07-28T12:44:53.543Z","repository":{"id":109916212,"uuid":"281452430","full_name":"prostomarkeloff/enum-to-types","owner":"prostomarkeloff","description":"Macro for generating pseudo-enums for type-level programming. ","archived":false,"fork":false,"pushed_at":"2020-07-21T16:48:51.000Z","size":3,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-14T03:38:19.743Z","etag":null,"topics":["enums","rust","type-level"],"latest_commit_sha":null,"homepage":"","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/prostomarkeloff.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2020-07-21T16:43:56.000Z","updated_at":"2021-06-16T23:49:44.000Z","dependencies_parsed_at":"2023-07-16T15:46:15.809Z","dependency_job_id":null,"html_url":"https://github.com/prostomarkeloff/enum-to-types","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prostomarkeloff/enum-to-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fenum-to-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fenum-to-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fenum-to-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fenum-to-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prostomarkeloff","download_url":"https://codeload.github.com/prostomarkeloff/enum-to-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prostomarkeloff%2Fenum-to-types/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267520129,"owners_count":24100816,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["enums","rust","type-level"],"created_at":"2024-10-09T13:34:39.174Z","updated_at":"2025-07-28T12:44:53.484Z","avatar_url":"https://github.com/prostomarkeloff.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enum-to-types\n\nMacro for generating pseudo-enums for type-level programming.\nThis is somewhat like https://github.com/fmease/tylift but implemented with `macro_rules!` syntax.\n\n## Install\n\n```toml\n[dependencies]\nenum-to-types = \"0.1.0\"\n```\n\n## Example\n\n```rust\nuse enum_to_types::enum_to_types;\nuse std::marker::PhantomData;\n\nenum_to_types!(AccessLevel; User, Admin);\n\nstruct DataStorage\u003cT: AccessLevel::AccessLevel\u003e(i32, PhantomData\u003cT\u003e);\n\nimpl\u003cT: AccessLevel::AccessLevel\u003e DataStorage\u003cT\u003e {\n     fn new(i: i32) -\u003e Self {\n         Self(i, PhantomData)\n     }\n}\n\ntrait ReadStorage\u003cT: AccessLevel::AccessLevel\u003e {\n    fn read(\u0026self) -\u003e i32;\n}\n\nimpl ReadStorage\u003cAccessLevel::Admin\u003e for DataStorage\u003cAccessLevel::User\u003e {\n     fn read(\u0026self) -\u003e i32 {\n         self.0\n     }\n}\n\nimpl ReadStorage\u003cAccessLevel::User\u003e for DataStorage\u003cAccessLevel::User\u003e {\n     fn read(\u0026self) -\u003e i32 {\n         self.0\n     }\n}\n\nimpl ReadStorage\u003cAccessLevel::Admin\u003e for DataStorage\u003cAccessLevel::Admin\u003e {\n     fn read(\u0026self) -\u003e i32 {\n         self.0\n     }\n}\n\nimpl ReadStorage\u003cAccessLevel::User\u003e for DataStorage\u003cAccessLevel::Admin\u003e {\n     fn read(\u0026self) -\u003e i32 {\n         panic!(\"You have no rights to read this\");\n     }\n}\n\nfn main() {\n     let storage = DataStorage::\u003cAccessLevel::Admin\u003e::new(1);\n     assert_eq!(\u003cDataStorage::\u003cAccessLevel::Admin\u003e as ReadStorage\u003cAccessLevel::Admin\u003e\u003e::read(\u0026storage), 1);\n     let storage = DataStorage::\u003cAccessLevel::User\u003e::new(5);\n     assert_eq!(\u003cDataStorage::\u003cAccessLevel::User\u003e as ReadStorage\u003cAccessLevel::User\u003e\u003e::read(\u0026storage), 5);\n     // reading storage with `AccessLevel::Admin` by user will cause panic\n}\n ```\n\nThis may look very verbose, but it gives a lot of flexibility.\nAlso, other examples can look less verbose.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprostomarkeloff%2Fenum-to-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprostomarkeloff%2Fenum-to-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprostomarkeloff%2Fenum-to-types/lists"}