{"id":16123323,"url":"https://github.com/kitlith/typemap_core","last_synced_at":"2025-07-03T17:33:03.117Z","repository":{"id":57670907,"uuid":"335189214","full_name":"kitlith/typemap_core","owner":"kitlith","description":"A map from a type to a value of that type, without needing alloc","archived":false,"fork":false,"pushed_at":"2023-09-14T22:34:59.000Z","size":41,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T13:59:26.678Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kitlith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-02-02T06:19:55.000Z","updated_at":"2024-07-14T06:38:46.000Z","dependencies_parsed_at":"2024-10-27T18:13:47.668Z","dependency_job_id":"ef550443-4e8a-4db6-9263-e01b491245cd","html_url":"https://github.com/kitlith/typemap_core","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"3f97afe6d401520ea8b7f6a326bc69cd1e3ccb81"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kitlith/typemap_core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitlith%2Ftypemap_core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitlith%2Ftypemap_core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitlith%2Ftypemap_core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitlith%2Ftypemap_core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitlith","download_url":"https://codeload.github.com/kitlith/typemap_core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitlith%2Ftypemap_core/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263369767,"owners_count":23456357,"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-09T21:15:33.546Z","updated_at":"2025-07-03T17:33:03.078Z","avatar_url":"https://github.com/kitlith.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typemap_core\n![Build Status](https://github.com/kitlith/typemap_core/workflows/Main/badge.svg)\n[![Current Crates.io Version](https://img.shields.io/crates/v/typemap_core.svg)](https://crates.io/crates/typemap_core)\n[![Current Documentation](https://docs.rs/typemap_core/badge.svg)](https://docs.rs/typemap_core)\n\n*A no_std typemap with trait-based value-presence guarantees (on nightly)*  \nor  \n*A map from a type to a value of that type, without needing std/alloc*\n\n## Context Example\n\n```rust\nuse typemap_core::{typemap, Contains};\n\nstruct A;\n\n#[derive(Debug)]\nstruct ContextA(u8);\n\n// Context types are encouraged to be newtypes with From impls,\n// so that when using the typemap! macro, you can use use the name\n// of the newtype as a kind of readable field name.\nimpl From\u003cu8\u003e for ContextA {\n    fn from(val: u8) -\u003e Self {\n        Self(val)\n    }\n}\n\nstruct B;\n\n#[derive(Debug)]\nstruct ContextB(u16);\n\nimpl From\u003cu16\u003e for ContextB {\n    fn from(val: u16) -\u003e Self {\n        Self(val)\n    }\n}\n\n#[allow(unused)]\nstruct C {\n    a: A,\n    b: B,\n}\n\ntrait ParseTrait\u003cCtx\u003e {\n    fn parse(context: Ctx) -\u003e Self;\n}\n\nimpl\u003cCtx\u003e ParseTrait\u003cCtx\u003e for A\nwhere\n    Ctx: Contains\u003cContextA\u003e,\n{\n    fn parse(context: Ctx) -\u003e Self {\n        println!(\"{:?}\", context.get::\u003cContextA\u003e());\n        A\n    }\n}\n\nimpl\u003cCtx\u003e ParseTrait\u003cCtx\u003e for B\nwhere\n    Ctx: Contains\u003cContextB\u003e,\n{\n    fn parse(context: Ctx) -\u003e Self {\n        println!(\"{:?}\", context.get::\u003cContextB\u003e());\n        B\n    }\n}\n\nimpl\u003cCtx\u003e ParseTrait\u003cCtx\u003e for C\nwhere\n    A: ParseTrait\u003cCtx\u003e,\n    B: ParseTrait\u003cCtx\u003e,\n    Ctx: Clone\n{\n    fn parse(context: Ctx) -\u003e Self {\n        Self {\n            a: A::parse(context.clone()),\n            b: B::parse(context)\n        }\n    }\n}\n\nfn main() {\n    let ctx = typemap!(ContextA = 0u8);\n\n    // Will panic at runtime on stable, and produce a compilation error on nightly\n    // C::parse(\u0026ctx);\n\n    // context can be extended \n    let ctx = typemap!(ContextB = 10u16, ..ctx);\n\n    // prints:\n    // ContextA(0)\n    // ContextB(10)\n    C::parse(\u0026ctx);\n\n    // and you can override earlier values of context without discarding them\n    let ctx = typemap!(ContextA = 5u8, ..ctx);\n\n    // prints:\n    // ContextA(5)\n    // ContextB(10)\n    C::parse(\u0026ctx);\n}\n```\n\n## Nightly\n\nThis crate contains the `Contains\u003cT\u003e` and `ContainsMut\u003cT\u003e` traits.\nThese traits are only implemented correctly on nightly due to missing features in stable,\nWhen using this library, you are encouraged to (occasionally) use the nightly compiler\nto catch errors in your constraints at compile-time rather than run-time,\neven if you are otherwise targeting stable.\n\nThis crate will properly implement those traits on stable as soon as we find a way to do so,\nbut for now they are implemented for all instances of `Ty\u003cT, Rest\u003e`\nso that code running on stable doesn't need to cfg out all instances of requiring those traits.\n\nHowever, some configurations involving references to the rest of the typemap and\noverriding existing values fail to compile on nightly without the use of `-Ztrait-solver=next`.\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0\n  (http://www.apache.org/licenses/LICENSE-2.0)\n* MIT license\n  (http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitlith%2Ftypemap_core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitlith%2Ftypemap_core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitlith%2Ftypemap_core/lists"}