Crates.io | getter-methods |
lib.rs | getter-methods |
version | 1.1.0 |
source | src |
created_at | 2023-09-19 21:29:12.849472 |
updated_at | 2024-05-30 23:04:09.722842 |
description | Derive macro to create getter / accessor methods. |
homepage | |
repository | https://github.com/lukesneeringer/getter-methods |
max_upload_size | |
id | 977250 |
size | 11,284 |
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.