{"id":16877407,"url":"https://github.com/juntyr/const-type-layout","last_synced_at":"2025-07-20T17:37:18.971Z","repository":{"id":46571439,"uuid":"412387050","full_name":"juntyr/const-type-layout","owner":"juntyr","description":"A derive trait which enables the const comparison of type layouts","archived":false,"fork":false,"pushed_at":"2024-11-26T18:59:44.000Z","size":5272,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-01T20:52:41.836Z","etag":null,"topics":["const-evaluation","const-generics","rust","type-layout"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/const-type-layout","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"LPGhatguy/type-layout","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juntyr.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":"2021-10-01T08:24:50.000Z","updated_at":"2024-11-25T16:51:55.000Z","dependencies_parsed_at":"2024-09-09T21:44:57.823Z","dependency_job_id":"aeda255c-d3d1-4d64-af26-2bbad73c8dcd","html_url":"https://github.com/juntyr/const-type-layout","commit_stats":{"total_commits":46,"total_committers":5,"mean_commits":9.2,"dds":0.4782608695652174,"last_synced_commit":"9785963a89bcc6495c7525f73ce6b0766c7aab9b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/juntyr/const-type-layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntyr%2Fconst-type-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntyr%2Fconst-type-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntyr%2Fconst-type-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntyr%2Fconst-type-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juntyr","download_url":"https://codeload.github.com/juntyr/const-type-layout/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juntyr%2Fconst-type-layout/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266166994,"owners_count":23886907,"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":["const-evaluation","const-generics","rust","type-layout"],"created_at":"2024-10-13T15:43:27.297Z","updated_at":"2025-07-20T17:37:18.950Z","avatar_url":"https://github.com/juntyr.png","language":"Rust","readme":"[![CI Status]][workflow] [![MSRV]][repo] [![Latest Version]][crates.io] [![Rust Doc Crate]][docs.rs] [![Rust Doc Main]][docs] [![License Status]][fossa] [![Code Coverage]][codecov]\n\n[CI Status]: https://img.shields.io/github/actions/workflow/status/juntyr/const-type-layout/ci.yml?branch=main\n[workflow]: https://github.com/juntyr/const-type-layout/actions/workflows/ci.yml?query=branch%3Amain\n\n[MSRV]: https://img.shields.io/badge/MSRV-1.78.0--nightly-orange\n[repo]: https://github.com/juntyr/const-type-layout\n\n[Latest Version]: https://img.shields.io/crates/v/const-type-layout\n[crates.io]: https://crates.io/crates/const-type-layout\n\n[Rust Doc Crate]: https://img.shields.io/docsrs/const-type-layout\n[docs.rs]: https://docs.rs/const-type-layout/\n\n[Rust Doc Main]: https://img.shields.io/badge/docs-main-blue\n[docs]: https://juntyr.github.io/const-type-layout/const_type_layout\n\n[License Status]: https://app.fossa.com/api/projects/custom%2B26490%2Fgithub.com%2Fjuntyr%2Fconst-type-layout.svg?type=shield\n[fossa]: https://app.fossa.com/projects/custom%2B26490%2Fgithub.com%2Fjuntyr%2Fconst-type-layout?ref=badge_shield\n\n[Code Coverage]: https://img.shields.io/codecov/c/github/juntyr/const-type-layout?token=J39WVBIMZX\n[codecov]: https://codecov.io/gh/juntyr/const-type-layout\n\n`const-type-layout` is a type layout comparison aid, providing a `#[derive]`able `TypeLayout` trait\nthat reports:\n- The type's name, size, and minimum alignment\n- The type's structure, i.e. struct vs. union vs. enum\n- Each field's name and offset\n- Each variant's name and discriminant\n\nThrough the auto-implemented `TypeGraphLayout` trait, the deep type layout is also reported as a graph.\n\nThis crate heavily builds on the original runtime [type-layout](https://github.com/LPGhatguy/type-layout) crate by Lucien Greathouse.\n\n## Examples\n\nThe layout of types is only defined if they're `#[repr(C)]`. This crate works on\nnon-`#[repr(C)]` types, but their layout is unpredictable.\n\n```rust\nuse const_type_layout::TypeLayout;\n\n#[derive(TypeLayout)]\n#[repr(C)]\nstruct Foo {\n    a: u8,\n    b: u32,\n}\n\nassert_eq!(\n    format!(\"{:#?}\", Foo::TYPE_LAYOUT),\nr#\"TypeLayoutInfo {\n    name: \"mycrate::mymodule::Foo\",\n    size: 8,\n    alignment: 4,\n    structure: Struct {\n        repr: \"C\",\n        fields: [\n            Field {\n                name: \"a\",\n                offset: Inhabited(\n                    0,\n                ),\n                ty: \"u8\",\n            },\n            Field {\n                name: \"b\",\n                offset: Inhabited(\n                    4,\n                ),\n                ty: \"u32\",\n            },\n        ],\n    },\n}\"#\n);\n```\n\nOver-aligned types have trailing padding, which can be a source of bugs in some\nFFI scenarios:\n\n```rust\nuse const_type_layout::TypeLayout;\n\n#[derive(TypeLayout)]\n#[repr(C, align(128))]\nstruct OverAligned {\n    value: u8,\n}\n\nassert_eq!(\n    format!(\"{:#?}\", OverAligned::TYPE_LAYOUT),\nr#\"TypeLayoutInfo {\n    name: \"mycrate::mymodule::OverAligned\",\n    size: 128,\n    alignment: 128,\n    structure: Struct {\n        repr: \"C,align(128)\",\n        fields: [\n            Field {\n                name: \"value\",\n                offset: Inhabited(\n                    0,\n                ),\n                ty: \"u8\",\n            },\n        ],\n    },\n}\"#\n)\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuntyr%2Fconst-type-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuntyr%2Fconst-type-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuntyr%2Fconst-type-layout/lists"}