4 releases

new 0.1.0 Jan 20, 2025
0.1.0-rc.1 Dec 17, 2024
0.1.0-pre.1 Oct 20, 2023
0.1.0-alpha.1 Oct 7, 2024

#2283 in Procedural macros

Download history 14/week @ 2024-09-24 126/week @ 2024-10-01 161/week @ 2024-10-08 21/week @ 2024-10-15 4/week @ 2024-10-22 4/week @ 2024-10-29 8/week @ 2024-11-05 1/week @ 2024-11-12 12/week @ 2024-11-19 6/week @ 2024-11-26 5/week @ 2024-12-03 33/week @ 2024-12-10 148/week @ 2024-12-17 4/week @ 2025-01-07

152 downloads per month
Used in 8 crates (3 directly)

Apache-2.0

20KB
414 lines

hax adt into

This crate provides the adt_into procedural macro, allowing for mirroring data types with small variations.

This crate is used by the frontend of hax, where we need to mirror a big part of the data types defined by the Rust compiler. While the abstract syntax trees (ASTs) from the Rust compiler expose a lot of indirections (identifiers one should lookup, additional informations reachable only via interactive queries), hax exposes the same ASTs, removing indirections and inlining additional informations.

The adt_into derive macro can be used on structs and enums. adt_into then looks for another #[args(<GENERICS>, from: FROM_TYPE, state: STATE_TYPE as SOME_NAME)] attribute. Such an attribute means that the struct or enum mirrors the type FROM_TYPE, and that the transformation is carried along with a state of type STATE_TYPE that will be accessible via the name SOME_NAME.

An example is available in the tests folder.

Dependencies

~2MB
~46K SLoC