getter-methods
This is getter-methods, a derive macro that will generate an impl with accessor methods for each
field on the struct.
Using getter-methods is straightforward: simply derive it:
use getter_methods::GetterMethods;
#[derive(GetterMethods)]
struct Foo {
bar: String,
baz: i64,
}
let foo = Foo { bar: "bacon".into(), baz: 42 };
assert_eq!(foo.bar(), "bacon");
assert_eq!(foo.baz(), 42);For more, see the documentation.
On this page
Languages
Rust100.0%
Contributors
MIT License
Created September 19, 2023
Updated June 19, 2025