Overview of getset
maingetset is a procedural macro crate for Rust that automatically generates basic getters and setters for struct fields. It reduces boilerplate for simple data access patterns where no custom logic is required within the accessors.
Generated Method Patterns:
- Getters:
fn field(&self) -> &type - Setters:
fn field(&mut self, val: type) -> &mut Self - With Setters:
fn with_field(mut self, val: type) -> Self - Mutable Getters:
fn field_mut(&mut self) -> &mut type - Copy Getters:
fn field(&self) -> type(for types implementingCopy) - Clone Getters:
fn field(&self) -> type(for types implementingClone, useful forArc)
Note: Do not use these macros for fields requiring custom logic; implement those manually.