{"id":20410916,"url":"https://github.com/mintlu8/ty_map_gen","last_synced_at":"2026-05-10T18:03:21.667Z","repository":{"id":240362447,"uuid":"802074760","full_name":"mintlu8/ty_map_gen","owner":"mintlu8","description":"A type projecting map generator.","archived":false,"fork":false,"pushed_at":"2024-05-19T03:32:16.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T08:03:36.667Z","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/mintlu8.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-05-17T13:25:01.000Z","updated_at":"2024-05-19T03:32:19.000Z","dependencies_parsed_at":"2024-05-18T10:24:10.976Z","dependency_job_id":"7cdddd61-cf5d-46a1-9885-9d387beb174f","html_url":"https://github.com/mintlu8/ty_map_gen","commit_stats":null,"previous_names":["mintlu8/ty_map_gen"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fty_map_gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fty_map_gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fty_map_gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintlu8%2Fty_map_gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintlu8","download_url":"https://codeload.github.com/mintlu8/ty_map_gen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241955047,"owners_count":20048405,"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-11-15T05:49:02.486Z","updated_at":"2026-05-10T18:03:21.596Z","avatar_url":"https://github.com/mintlu8.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ty_map_gen\n\n[![Crates.io](https://img.shields.io/crates/v/ty_map_gen.svg)](https://crates.io/crates/ty_map_gen)\n[![Docs](https://docs.rs/ty_map_gen/badge.svg)](https://docs.rs/ty_map_gen/latest/ty_map_gen/)\n\nA type projecting map generator.\n\n## Syntax\n\n```rust\ntype_map!(\n    /// Asset Map\n    #[derive(Clone, PartialEq, Eq)]\n    pub AssetMap where T [Asset] =\u003e Handle\u003cT\u003e [Clone + Eq] as HashMap\n);\n```\n\nThis creates a type that projects `T` (a generic) to `Handle\u003cT\u003e` (roughly):\n\n```rust\npub struct AssetMap(HashMap\u003cTypeId, Box\u003cdyn Any\u003e\u003e)\n```\n\nwith access methods (roughly):\n\n```rust\nfn get\u003cT: Asset + 'static\u003e(\u0026self) -\u003e Option\u003c\u0026Handle\u003cT\u003e\u003e where Handle\u003cT\u003e: Clone + Eq {\n    self.0.get(TypeId::of::\u003cT\u003e()).and_then(|v| v.downcast_ref())\n}\n```\n\nSince all values stored in the map are `Clone` and `Eq`, they can be derived.\n\nThe `as HashMap` field accepts all structs that has the same api\nas `HashMap`, this includes `BTreeMap` and third party types\nlike `FxHashMap` or `VecMap`. To specify a custom hasher, you must\ndefine a new `type` with signature `Map\u003cKey, Value\u003e`.\n\n## Bounds\n\nBounds (in braces `[]`) are optional in the macro. The bounds on the right hand side must be object safe,\nexcluding `Clone`, `PartialEq`, `Eq`, `Ord`, `PartialOrd`, `Hash` and `Serialize`,\nwhich are special handled. Additionally only one trait from `std::cmp` is allowed to be specified.\nIf you need `Send` and `Sync` this is where to add them.\n\nCurrently the right hand side uses a unique scope, therefore you must supply fully qualified trait paths.\n\n## Methods and Implementations\n\nBy default these methods are generated by the macro:\n\n`Default`, `new`, `is_empty`, `len`, `get`, `get_mut`, `insert`, `remove`, `clear`, `extend`.\n\n## Double Keys\n\n```rust\ntype_map!(\n    /// Asset Map\n    #[derive(Clone, PartialEq, Eq)]\n    pub AssetMap where (T, String) [Asset] =\u003e Handle\u003cT\u003e [Clone + Eq] as HashMap\n);\n```\n\nThis adds another key to the map, with access methods (roughly):\n\n```rust\nfn get\u003cT: Asset + 'static\u003e(\u0026self, key: \u0026Q) -\u003e Option\u003c\u0026Handle\u003cT\u003e\u003e where Handle\u003cT\u003e: Clone + Eq {\n    self.0.get(\u0026(TypeId::of::\u003cT\u003e(), key)).and_then(|v| v.downcast_ref())\n}\n```\n\n## Performance\n\nThis crate has faster lookup (`get` and `get_mut`) than a naive implementation with `Box\u003cdyn Any\u003e`\nsince downcasting is unchecked.\n\n## License\n\nLicense under either of\n\nApache License, Version 2.0 (LICENSE-APACHE or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\nMIT license (LICENSE-MIT or \u003chttp://opensource.org/licenses/MIT\u003e)\nat your option.\n\n## Contribution\n\nContributions are welcome!\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fty_map_gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintlu8%2Fty_map_gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintlu8%2Fty_map_gen/lists"}