#struct-fields #iterator #field

macro metastruct_macro

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

5 releases

0.1.4 Jan 15, 2026
0.1.3 Nov 22, 2024
0.1.2 Jul 18, 2024
0.1.1 Jun 19, 2023
0.1.0 Dec 8, 2022

#103 in #struct-fields

Download history 4467/week @ 2025-10-07 4435/week @ 2025-10-14 3952/week @ 2025-10-21 3504/week @ 2025-10-28 3706/week @ 2025-11-04 2240/week @ 2025-11-11 2255/week @ 2025-11-18 3093/week @ 2025-11-25 2850/week @ 2025-12-02 2577/week @ 2025-12-09 2357/week @ 2025-12-16 905/week @ 2025-12-23 1205/week @ 2025-12-30 2595/week @ 2026-01-06 2452/week @ 2026-01-13 3021/week @ 2026-01-20

9,475 downloads per month
Used in metastruct

Apache-2.0

18KB
418 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

~1–1.4MB
~31K SLoC