{"id":13648551,"url":"https://github.com/QuarticCat/enum-ptr","last_synced_at":"2025-04-22T11:32:47.133Z","repository":{"id":62328858,"uuid":"559178700","full_name":"QuarticCat/enum-ptr","owner":"QuarticCat","description":"Ergonomic tagged pointer","archived":false,"fork":false,"pushed_at":"2023-08-25T02:37:21.000Z","size":159,"stargazers_count":28,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-29T10:12:51.043Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/enum-ptr","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/QuarticCat.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}},"created_at":"2022-10-29T09:57:26.000Z","updated_at":"2023-10-11T08:49:38.000Z","dependencies_parsed_at":"2024-01-14T10:59:29.045Z","dependency_job_id":"8f0cae7c-dfd9-4ecd-b1e2-e34d9e336995","html_url":"https://github.com/QuarticCat/enum-ptr","commit_stats":{"total_commits":75,"total_committers":2,"mean_commits":37.5,"dds":"0.21333333333333337","last_synced_commit":"25baf5aed44f55d0e26b0818d7eeb4783b8b56c3"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuarticCat%2Fenum-ptr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuarticCat%2Fenum-ptr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuarticCat%2Fenum-ptr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuarticCat%2Fenum-ptr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuarticCat","download_url":"https://codeload.github.com/QuarticCat/enum-ptr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250232390,"owners_count":21396631,"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":["rust"],"created_at":"2024-08-02T01:04:20.592Z","updated_at":"2025-04-22T11:32:46.780Z","avatar_url":"https://github.com/QuarticCat.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Enum Ptr\n\n[![crates.io](https://img.shields.io/crates/v/enum-ptr)](https://crates.io/crates/enum-ptr)\n[![docs.rs](https://img.shields.io/badge/docs.rs-enum--ptr-latest)](https://docs.rs/enum-ptr)\n\nThis crate provides a custom derive macro `EnumPtr` to generate bridges between an enum `T` and `Compact\u003cT\u003e` with minimum cost. `Compact\u003cT\u003e` is the compact representation of `T`, and it is only one pointer wide.\nIn other words, this crate is a library for defining tagged pointers in ergonomic way, even supporting different pointer types (`\u0026`, `Box`, `Arc`, etc) as different `enum` variants.\n\nFor example, the following code\n\n```rust\nuse enum_ptr::EnumPtr;\n\n#[derive(EnumPtr)]\n#[repr(C, usize)]\nenum Foo\u003c'a\u003e {\n    A(\u0026'a i32),\n    B(Box\u003ci32\u003e),\n}\n```\n\nwill generate\n\n```rust\nimpl\u003c'a\u003e From\u003cFoo\u003c'a\u003e\u003e for Compact\u003cFoo\u003c'a\u003e\u003e {\n    // ...\n}\n\nimpl\u003c'a\u003e From\u003cCompact\u003cFoo\u003c'a\u003e\u003e\u003e for Foo\u003c'a\u003e {\n    // ...\n}\n```\n\nSince `\u0026i32` and `Box\u003ci32\u003e` are aligned by 4 bytes, the lowest 2 bits of them are always zeros. `Compact\u003cFoo\u003c'a\u003e\u003e` utilizes these bits to store the tag (discriminant).\n\n## Features\n\n- No need to write unsafe pointer operations\n- Supports various types and can be extended\n- Supports `no_std`\n- Minimum type conversion cost\n- Passes `cargo +nightly miri test` with strict provenance enabled.\n\n## Testing\n\n```console\n$ cargo test\n$ cargo +nightly miri test\n```\n\n## Credits\n\n- Thanks to [@oxalica](https://github.com/oxalica) for reviewing this crate and providing a lot of helpful suggestions.\n\n## License\n\nThis project is licensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](/LICENSE-APACHE) or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0))\n- MIT license ([LICENSE-MIT](/LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT))\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQuarticCat%2Fenum-ptr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FQuarticCat%2Fenum-ptr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQuarticCat%2Fenum-ptr/lists"}