@@ -76,10 +76,10 @@ pub(crate) use syn::{
7676/// data: vec![1, 2, 3],
7777/// };
7878/// let name_ref: &String = basic.get_name();
79- /// let desc_ref : &String = basic.get_description();
79+ /// let description_ref : &String = basic.get_description();
8080/// let data_clone: Vec<i32> = basic.get_data();
8181/// assert_eq!(*name_ref, "test");
82- /// assert_eq!(*desc_ref , "description");
82+ /// assert_eq!(*description_ref , "description");
8383/// assert_eq!(data_clone, vec![1, 2, 3]);
8484/// ```
8585///
@@ -91,22 +91,22 @@ pub(crate) use syn::{
9191/// #[derive(Getter, Clone)]
9292/// struct OptionalStruct {
9393/// #[get(pub)]
94- /// optional: Option<String>, // Default: returns Option<String> (cloned)
94+ /// optional: Option<String>,
9595/// #[get(pub, reference)]
96- /// optional_ref: Option<String>, // Returns &Option<String>
96+ /// optional_ref: Option<String>,
9797/// #[get(pub)]
98- /// result: Result<String, String>, // Default: returns Result<String, String> (cloned)
98+ /// result: Result<String, String>,
9999/// }
100100/// let opt_struct = OptionalStruct {
101101/// optional: Some("value".to_string()),
102102/// optional_ref: Some("ref_value".to_string()),
103103/// result: Ok("success".to_string()),
104104/// };
105- /// let opt_value : String = opt_struct.get_optional();
106- /// let opt_ref : &Option<String> = opt_struct.get_optional_ref();
105+ /// let optional_value : String = opt_struct.get_optional();
106+ /// let optional_reference : &Option<String> = opt_struct.get_optional_ref();
107107/// let result_value: String = opt_struct.get_result();
108- /// assert_eq!(opt_value , "value");
109- /// assert_eq!(*opt_ref , Some("ref_value".to_string()));
108+ /// assert_eq!(optional_value , "value");
109+ /// assert_eq!(*optional_reference , Some("ref_value".to_string()));
110110/// assert_eq!(result_value, "success");
111111/// ```
112112///
@@ -171,22 +171,22 @@ pub fn getter(input: TokenStream) -> TokenStream {
171171/// use lombok_macros::*;
172172///
173173/// #[derive(GetterMut, Clone)]
174- /// struct LombokTest2 <'a, 'b, T: Clone> {
174+ /// struct StructWithLifetimes <'a, 'b, T: Clone> {
175175/// #[get_mut(pub(crate))]
176176/// list: Vec<String>,
177177/// #[get_mut(pub(crate))]
178- /// opt_str_lifetime_a : Option<&'a T>,
179- /// opt_str_lifetime_b : Option<&'b str>,
178+ /// optional_lifetime_a : Option<&'a T>,
179+ /// optional_lifetime_b : Option<&'b str>,
180180/// }
181181/// let list: Vec<String> = vec!["hello".to_string(), "world".to_string()];
182- /// let mut data2: LombokTest2 <usize> = LombokTest2 {
182+ /// let mut struct_with_lifetimes: StructWithLifetimes <usize> = StructWithLifetimes {
183183/// list: list.clone(),
184- /// opt_str_lifetime_a : None,
185- /// opt_str_lifetime_b : None,
184+ /// optional_lifetime_a : None,
185+ /// optional_lifetime_b : None,
186186/// };
187- /// let mut get_list : &mut Vec<String> = data2 .get_mut_list();
188- /// get_list .push("new_item".to_string());
189- /// assert_eq!(*get_list , vec!["hello".to_string(), "world".to_string(), "new_item".to_string()]);
187+ /// let mut list_reference : &mut Vec<String> = struct_with_lifetimes .get_mut_list();
188+ /// list_reference .push("new_item".to_string());
189+ /// assert_eq!(*list_reference , vec!["hello".to_string(), "world".to_string(), "new_item".to_string()]);
190190/// ```
191191#[ proc_macro_derive( GetterMut , attributes( get_mut) ) ]
192192pub fn getter_mut ( input : TokenStream ) -> TokenStream {
@@ -246,23 +246,20 @@ pub fn getter_mut(input: TokenStream) -> TokenStream {
246246/// #[derive(Setter, Debug, Clone)]
247247/// struct ConversionStruct {
248248/// #[set(pub, Into)]
249- /// name: String, // Accepts any type that implements Into<String>
249+ /// name: String,
250250/// #[set(pub, AsRef)]
251- /// description: String, // Accepts any type that implements AsRef<str>
251+ /// description: String,
252252/// }
253- /// let mut conv = ConversionStruct {
253+ /// let mut conversion_struct = ConversionStruct {
254254/// name: "initial".to_string(),
255255/// description: "desc".to_string(),
256256/// };
257257///
258- /// // Using Into trait: &str implements Into<String>
259- /// conv.set_name("from_str");
260- ///
261- /// // Using AsRef trait: &str implements AsRef<str>
262- /// conv.set_description("from_str_ref");
258+ /// conversion_struct.set_name("from_str");
259+ /// conversion_struct.set_description("from_str_ref");
263260///
264- /// assert_eq!(conv .name, "from_str");
265- /// assert_eq!(conv .description, "from_str_ref");
261+ /// assert_eq!(conversion_struct .name, "from_str");
262+ /// assert_eq!(conversion_struct .description, "from_str_ref");
266263/// ```
267264///
268265/// ## Tuple Structs
@@ -330,24 +327,24 @@ pub fn setter(input: TokenStream) -> TokenStream {
330327/// };
331328///
332329/// // Using getters
333- /// let name_ref : &String = user.get_name();
330+ /// let name_reference : &String = user.get_name();
334331/// let email_clone: String = user.get_email();
335- /// assert_eq!(*name_ref , "Alice");
332+ /// assert_eq!(*name_reference , "Alice");
336333/// assert_eq!(email_clone, "alice@example.com");
337334///
338335/// // Using setters with trait conversion
339336/// user.set_name("Bob".to_string());
340- /// user.set_email("bob@example.com"); // &str implements Into<String>
337+ /// user.set_email("bob@example.com");
341338///
342339/// // Verify setters worked
343340/// let updated_email: String = user.get_email();
344341/// assert_eq!(updated_email, "bob@example.com");
345342///
346343/// // Using mutable getters
347- /// let age_mut : &mut u32 = user.get_mut_age();
348- /// *age_mut = 31;
344+ /// let age_mutable_reference : &mut u32 = user.get_mut_age();
345+ /// *age_mutable_reference = 31;
349346///
350- /// assert_eq!(*age_mut , 31);
347+ /// assert_eq!(*age_mutable_reference , 31);
351348/// ```
352349///
353350/// ## Multiple Field Types
@@ -357,20 +354,13 @@ pub fn setter(input: TokenStream) -> TokenStream {
357354///
358355/// #[derive(Data, Debug, Clone)]
359356/// struct ComplexStruct {
360- /// // Regular field with default getter behavior
361357/// #[get(pub)]
362358/// id: i32,
363- ///
364- /// // Optional field - automatically returns cloned Option
365359/// #[get(pub)]
366360/// #[set(pub)]
367361/// optional: Option<String>,
368- ///
369- /// // Result field - automatically returns cloned Result
370362/// #[get(pub, reference)]
371363/// result: Result<i32, String>,
372- ///
373- /// // Private field with restricted access
374364/// #[get(pub(crate))]
375365/// #[set(private)]
376366/// internal_data: Vec<u8>,
@@ -383,14 +373,13 @@ pub fn setter(input: TokenStream) -> TokenStream {
383373/// internal_data: vec![1, 2, 3],
384374/// };
385375///
386- /// // Default getter behavior: reference for non-Option/Result, clone for Option/Result
387- /// let id_ref: &i32 = complex.get_id();
388- /// let opt_clone: String = complex.get_optional();
389- /// let result_ref: &Result<i32, String> = complex.get_result();
376+ /// let id_reference: &i32 = complex.get_id();
377+ /// let optional_clone: String = complex.get_optional();
378+ /// let result_reference: &Result<i32, String> = complex.get_result();
390379///
391- /// assert_eq!(*id_ref , 1);
392- /// assert_eq!(opt_clone , "value");
393- /// assert_eq!(*result_ref , Ok(42));
380+ /// assert_eq!(*id_reference , 1);
381+ /// assert_eq!(optional_clone , "value");
382+ /// assert_eq!(*result_reference , Ok(42));
394383/// ```
395384///
396385/// ## Tuple Struct with Combined Accessors
@@ -406,15 +395,15 @@ pub fn setter(input: TokenStream) -> TokenStream {
406395/// );
407396///
408397/// let mut point = Point(1.0, 2.0);
409- /// let x_ref : &f64 = point.get_0();
410- /// let y_clone : f64 = point.get_1();
398+ /// let x_coordinate : &f64 = point.get_0();
399+ /// let y_coordinate : f64 = point.get_1();
411400///
412- /// assert_eq!(*x_ref , 1.0);
413- /// assert_eq!(y_clone , 2.0);
401+ /// assert_eq!(*x_coordinate , 1.0);
402+ /// assert_eq!(y_coordinate , 2.0);
414403///
415404/// point.set_1(3.0);
416- /// let y_after_set : f64 = point.get_1();
417- /// assert_eq!(y_after_set , 3.0);
405+ /// let updated_y_coordinate : f64 = point.get_1();
406+ /// assert_eq!(updated_y_coordinate , 3.0);
418407/// ```
419408#[ proc_macro_derive( Data , attributes( get, get_mut, set) ) ]
420409pub fn data ( input : TokenStream ) -> TokenStream {
@@ -584,7 +573,7 @@ pub fn custom_debug(input: TokenStream) -> TokenStream {
584573/// let user = User::new("alice".to_string(), "alice@example.com".to_string());
585574/// assert_eq!(user.username, "alice");
586575/// assert_eq!(user.email, "alice@example.com");
587- /// assert_eq!(user.created_at, ""); // skipped field defaults to empty string
576+ /// assert_eq!(user.created_at, "");
588577/// ```
589578///
590579/// ## With Custom Visibility
@@ -597,7 +586,6 @@ pub fn custom_debug(input: TokenStream) -> TokenStream {
597586/// value: i32,
598587/// }
599588///
600- /// // Generated constructor: pub(crate) fn new(value: i32) -> Self
601589/// let internal = InternalStruct::new(42);
602590/// assert_eq!(internal.value, 42);
603591/// ```
@@ -630,7 +618,7 @@ pub fn custom_debug(input: TokenStream) -> TokenStream {
630618///
631619/// let container = Container::new("data".to_string());
632620/// assert_eq!(container.data, "data");
633- /// assert_eq!(container.count, 0); // default value for usize
621+ /// assert_eq!(container.count, 0);
634622/// ```
635623///
636624/// # Parameters
0 commit comments