{"id":29101862,"url":"https://github.com/tyilo/exhaustive-map","last_synced_at":"2025-08-24T02:19:17.758Z","repository":{"id":233639379,"uuid":"787616853","full_name":"tyilo/exhaustive-map","owner":"tyilo","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-09T01:12:45.000Z","size":86,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T02:25:57.071Z","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/tyilo.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}},"created_at":"2024-04-16T21:30:07.000Z","updated_at":"2025-08-09T01:12:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"660667f6-59e9-4735-b3cc-3b34f6ae3209","html_url":"https://github.com/tyilo/exhaustive-map","commit_stats":null,"previous_names":["tyilo/exhaustive-map"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tyilo/exhaustive-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fexhaustive-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fexhaustive-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fexhaustive-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fexhaustive-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyilo","download_url":"https://codeload.github.com/tyilo/exhaustive-map/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fexhaustive-map/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271780500,"owners_count":24819293,"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-08-24T02:00:11.135Z","response_time":111,"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":[],"created_at":"2025-06-28T21:08:34.407Z","updated_at":"2025-08-24T02:19:17.751Z","avatar_url":"https://github.com/tyilo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# exhaustive-map [![Latest Version]][crates.io] [![API Docs]][docs.rs]\n\n[Latest Version]: https://img.shields.io/crates/v/exhaustive-map.svg\n[crates.io]: https://crates.io/crates/exhaustive-map\n[API Docs]: https://img.shields.io/docsrs/exhaustive-map.svg\n[docs.rs]: https://docs.rs/exhaustive-map\n\nAn exhaustive map for types with finite inhabitants.\n\nExample usage:\n```rust\nuse exhaustive_map::ExhaustiveMap;\n\nlet mut map = ExhaustiveMap::\u003cu8, u16\u003e::from_fn(|i| i as u16 + 100);\nassert_eq!(map.len(), 256);\n\nassert_eq!(map[3], 103);\n\nmap[7] = 9999;\nassert_eq!(map[7], 9999);\n\nmap.swap(7, 3);\nassert_eq!(map[3], 9999);\nassert_eq!(map[7], 103);\n```\n\nThe key type must implement the `Finite` trait.\nYou can implement this for your own types using derive:\n```rust\nuse exhaustive_map::{Finite, FiniteExt};\n\n#[derive(Finite, Debug, PartialEq)]\nenum Color {\n    Red,\n    Green,\n    Blue,\n}\n\nlet all: Vec\u003c_\u003e = Color::iter_all().collect();\nassert_eq!(all, vec![Color::Red, Color::Green, Color::Blue]);\n```\n\nThe `Finite` trait can also be implemented manually:\n```rust\nuse exhaustive_map::{Finite, typenum::consts::U3};\n\n#[derive(Debug, PartialEq)]\nenum Color {\n    Red,\n    Green,\n    Blue,\n}\n\nimpl Finite for Color {\n    type INHABITANTS = U3;\n\n    fn to_usize(\u0026self) -\u003e usize {\n        match self {\n            Self::Red =\u003e 0,\n            Self::Green =\u003e 1,\n            Self::Blue =\u003e 2,\n        }\n    }\n\n    fn from_usize(i: usize) -\u003e Option\u003cSelf\u003e {\n        Some(match i {\n            0 =\u003e Self::Red,\n            1 =\u003e Self::Green,\n            2 =\u003e Self::Blue,\n            _ =\u003e return None,\n        })\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyilo%2Fexhaustive-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyilo%2Fexhaustive-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyilo%2Fexhaustive-map/lists"}