#field #iterator #macro

metastruct

Abstractions for iterating and mapping over struct fields

1 unstable release

0.1.0 Dec 8, 2022

#1294 in Rust patterns

Download history 3647/week @ 2023-02-05 3600/week @ 2023-02-12 2681/week @ 2023-02-19 3351/week @ 2023-02-26 3448/week @ 2023-03-05 3302/week @ 2023-03-12 3799/week @ 2023-03-19 3276/week @ 2023-03-26 2389/week @ 2023-04-02 2622/week @ 2023-04-09 2516/week @ 2023-04-16 2197/week @ 2023-04-23 2439/week @ 2023-04-30 1689/week @ 2023-05-07 3070/week @ 2023-05-14 2216/week @ 2023-05-21

9,447 downloads per month

Custom license

7KB

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–290KB