Getter

Derive Macro Getter 

Source
#[derive(Getter)]
{
    // Attributes available to this derive:
    #[get]
}
Expand description

This is an example of how to use the Lombok procedural macro with get attributes.

The Lombok procedural macro is used to automatically generate getter methods for struct fields. The get attribute controls the visibility of the generated getter method.

Example:

use lombok_macros::*;

#[derive(Getter, Clone)]
struct LombokTest2<'a, 'b, T: Clone> {
    #[get(pub(crate))]
    list: Vec<String>,
    #[get(pub(crate))]
    opt_str_lifetime_a: Option<&'a T>,
    opt_str_lifetime_b: Option<&'b str>,
}
let list: Vec<String> = vec!["hello".to_string(), "world".to_string()];
let data2: LombokTest2<usize> = LombokTest2 {
    list: list.clone(),
    opt_str_lifetime_a: None,
    opt_str_lifetime_b: None,
};
let get_list: Vec<String> = data2.get_list().clone();
assert_eq!(get_list, list);