#struct-fields #field #macro #iterator #proc-macro #generate

macro metastruct_macro

Abstractions for iterating and mapping over struct fields (proc macro crate)

2 releases

0.1.1 Jun 19, 2023
0.1.0 Dec 8, 2022

#103 in #struct-fields

Download history 2352/week @ 2023-12-10 1601/week @ 2023-12-17 477/week @ 2023-12-24 1373/week @ 2023-12-31 2699/week @ 2024-01-07 3020/week @ 2024-01-14 2925/week @ 2024-01-21 3068/week @ 2024-01-28 3794/week @ 2024-02-04 1592/week @ 2024-02-11 2129/week @ 2024-02-18 2030/week @ 2024-02-25 2282/week @ 2024-03-03 2044/week @ 2024-03-10 2441/week @ 2024-03-17 2032/week @ 2024-03-24

8,868 downloads per month
Used in metastruct

Custom license

18KB
409 lines

metastruct

Metastruct is Rust library for metaprogramming with struct fields.

Some of the things you can do with metastruct include:

  • Iterate over a struct's fields.
  • Map a closure over all or some of a struct's fields.
  • Access the number of fields in a struct at compile-time via a const.

This is achieved by a procedural macro, which generates macro_rules! macros.

One way of understanding metastruct is as a shortcut to writing your own derive macros. If you have a trait that you'd like to implement on a one-off basis, metastruct can help you write that implementation without a derive macro.

🚧 Under Construction 🚧

This library is currently under construction and should not be considered stable.

There's currently no documentation aside from a few scant code comments and examples/tests.

License

Apache 2.0

Dependencies

~2MB
~50K SLoC