GetterMut

Derive Macro GetterMut 

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

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

The Lombok procedural macro is used to automatically generate mutable getters for struct fields. The get_mut attribute controls the visibility of the mutable getter function.

Example:

use lombok_macros::*;

#[derive(GetterMut, Clone)]
struct LombokTest2<'a, 'b, T: Clone> {
    #[get_mut(pub(crate))]
    list: Vec<String>,
    #[get_mut(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 mut data2: LombokTest2<usize> = LombokTest2 {
    list: list.clone(),
    opt_str_lifetime_a: None,
    opt_str_lifetime_b: None,
};
let get_list: Vec<String> = data2.get_mut_list().clone();
assert_eq!(get_list, list);