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

metastruct

Abstractions for iterating and mapping over struct fields

4 releases

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

#274 in Rust patterns

Download history 1744/week @ 2024-10-24 1499/week @ 2024-10-31 927/week @ 2024-11-07 1236/week @ 2024-11-14 1973/week @ 2024-11-21 2367/week @ 2024-11-28 1806/week @ 2024-12-05 2198/week @ 2024-12-12 1159/week @ 2024-12-19 331/week @ 2024-12-26 1928/week @ 2025-01-02 3179/week @ 2025-01-09 2324/week @ 2025-01-16 2154/week @ 2025-01-23 2975/week @ 2025-01-30 3211/week @ 2025-02-06

11,308 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

~0–370KB