Skip to content

Commit a3a7e2b

Browse files
committed
feat: v1.12.1
1 parent 89186a7 commit a3a7e2b

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lombok-macros"
3-
version = "1.12.0"
3+
version = "1.12.1"
44
edition = "2024"
55
authors = ["root@ltpp.vip"]
66
license = "MIT"

debug/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(warnings)]
2+
13
use lombok_macros::*;
24
use std::fmt::Debug;
35

@@ -14,13 +16,21 @@ where
1416
#[set(private)]
1517
#[get_mut(pub(crate))]
1618
opt_str_lifetime_b: Option<&'b str>,
19+
r#type: &'a str,
20+
}
21+
22+
impl<'a, 'b, T: Clone + Debug> LombokTest<'a, 'b, T> {
23+
pub fn test_type(&self) {
24+
self.r#type;
25+
}
1726
}
1827

1928
fn main() {
2029
let mut data: LombokTest<usize> = LombokTest {
2130
list: Vec::new(),
2231
opt_str_lifetime_a: None,
2332
opt_str_lifetime_b: None,
33+
r#type: "type",
2434
};
2535
let list: Vec<String> = vec!["hello".to_string(), "world".to_string()];
2636
data.set_list(list.clone());

src/generate/fn.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
use crate::*;
22

3+
fn get_clean_attr_name(attr_str: &str) -> String {
4+
let clean_attr: String = if let Some(stripped) = attr_str.strip_prefix("r#") {
5+
stripped.to_owned()
6+
} else {
7+
attr_str.to_owned()
8+
};
9+
clean_attr
10+
}
11+
312
/// Generates getter and setter functions for a given struct field.
413
///
514
/// # Parameters
@@ -22,9 +31,10 @@ pub fn generate_getter_setter(
2231
.to_string();
2332
let attr_name_ident: &Ident = field.ident.as_ref().unwrap();
2433
let attr_ty: &Type = &field.ty;
25-
let get_name: Ident = format_ident!("{}{}", GET_METHOD_PREFIX, attr_name);
26-
let get_mut_name: Ident = format_ident!("{}{}", GET_MUT_METHOD_PREFIX, attr_name);
27-
let set_name: Ident = format_ident!("{}{}", SET_METHOD_PREFIX, attr_name);
34+
let clean_attr_name: String = get_clean_attr_name(&attr_name);
35+
let get_name: Ident = format_ident!("{}{}", GET_METHOD_PREFIX, clean_attr_name);
36+
let get_mut_name: Ident = format_ident!("{}{}", GET_MUT_METHOD_PREFIX, clean_attr_name);
37+
let set_name: Ident = format_ident!("{}{}", SET_METHOD_PREFIX, clean_attr_name);
2838
let mut generated: NewTokenStream = quote! {};
2939
let mut cfg_map: HashMap<String, Vec<Cfg>> = HashMap::new();
3040
for attr in &field.attrs {

0 commit comments

Comments
 (0)