6 releases

Uses new Rust 2024

new 0.1.5 May 17, 2025
0.1.4 May 17, 2025

#377 in Procedural macros

Download history 257/week @ 2025-05-11

257 downloads per month

MIT/Apache

42KB
938 lines

⛏️ fieldwork – field accessor generation

crates.io version badge

fieldwork is a procedural macro crate designed to automate the generation of field accessor methods for named structs. By leveraging Rust's powerful macro system, fieldwork reduces boilerplate code, enhances code readability, and ensures consistency. Just as importantly, fieldwork intends to be fully customizable and expressive for common access patterns.

Manually writing getters and setters for struct fields is repetitive, and adds to maintenance burden. fieldwork addresses this by providing a procedural macro that automatically generates these methods based on your struct definitions. The intent of this crate, and distinguishing feature, is to be as customizable and expressive as writing your own getters and setters. The crate succeeds if you are able to emit exactly the code that you would have manually written, but far more concisely.

Performance

The compile time cost of using a proc macro crate is always worth considering. All efforts have been made to keep this crate as lightweight as possible and featureful enough to be worth the tradeoff.

Testing

ci codecov

This crate has a full suite of macro-expansion tests in tests/expand. These tests are also used for test coverage.

Documentation

View the docs for main on github at docs.md, or on github pages in rustdoc format. The most recent release can always be viewed at docs.rs.

Safety

This crate uses #![deny(unsafe_code)].

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~185–610KB
~15K SLoC