#struct-fields #iterator #field

metastruct

Abstractions for iterating and mapping over struct fields

5 releases

new 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

#419 in Rust patterns

Download history 3302/week @ 2025-09-27 3937/week @ 2025-10-04 4276/week @ 2025-10-11 4249/week @ 2025-10-18 3389/week @ 2025-10-25 4012/week @ 2025-11-01 2535/week @ 2025-11-08 1718/week @ 2025-11-15 3174/week @ 2025-11-22 3052/week @ 2025-11-29 2333/week @ 2025-12-06 2800/week @ 2025-12-13 1225/week @ 2025-12-20 982/week @ 2025-12-27 2322/week @ 2026-01-03 2600/week @ 2026-01-10

7,466 downloads per month

Apache-2.0

4KB

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

~220KB