Skip to content

Commit e83e56a

Browse files
authored
Merge pull request #167 from the-wondersmith/fix/fallback-setter-method-name
fix: malformed fallback setter method names
2 parents cf9bf18 + 3464c22 commit e83e56a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = [".", "./typed-builder-macro"]
33

44
[workspace.package]
55
description = "Compile-time type-checked builder derive"
6-
version = "0.21.0"
6+
version = "0.21.1"
77
authors = ["IdanArye <[email protected]>", "Chris Morgan <[email protected]>"]
88
edition = "2021"
99
license = "MIT OR Apache-2.0"
@@ -27,4 +27,4 @@ keywords.workspace = true
2727
categories.workspace = true
2828

2929
[dependencies]
30-
typed-builder-macro = { path = "typed-builder-macro", version = "=0.21.0" }
30+
typed-builder-macro = { path = "typed-builder-macro", version = "=0.21.1" }

typed-builder-macro/src/struct_info.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ use proc_macro2::{Ident, Span, TokenStream};
22
use quote::{format_ident, quote, quote_spanned, ToTokens};
33
use syn::{parse::Error, parse_quote, punctuated::Punctuated, GenericArgument, ItemFn, Token};
44

5-
use crate::builder_attr::{IntoSetting, TypeBuilderAttr};
6-
use crate::field_info::FieldInfo;
7-
use crate::mutator::Mutator;
8-
use crate::util::{
9-
empty_type, empty_type_tuple, first_visibility, modify_types_generics_hack, phantom_data_for_generics, public_visibility,
10-
strip_raw_ident_prefix, type_tuple,
5+
use crate::{
6+
builder_attr::{IntoSetting, TypeBuilderAttr},
7+
field_info::FieldInfo,
8+
mutator::Mutator,
9+
util::{
10+
empty_type, empty_type_tuple, first_visibility, modify_types_generics_hack, phantom_data_for_generics, public_visibility,
11+
strip_raw_ident_prefix, type_tuple,
12+
},
1113
};
1214

1315
#[derive(Debug)]
@@ -305,9 +307,10 @@ impl<'a> StructInfo<'a> {
305307
} else if strip_option.fallback_prefix.is_none() && strip_option.fallback_suffix.is_none() {
306308
None
307309
} else {
310+
let method = strip_raw_ident_prefix(field_name.to_string());
308311
let prefix = strip_option.fallback_prefix.as_deref().unwrap_or_default();
309312
let suffix = strip_option.fallback_suffix.as_deref().unwrap_or_default();
310-
let fallback_name = syn::Ident::new(&format!("{}{}{}", prefix, field_name, suffix), field_name.span());
313+
let fallback_name = syn::Ident::new(&format!("{}{}{}", prefix, method, suffix), field_name.span());
311314
Some((fallback_name, quote!(#field_name: #field_type), quote!(#arg_expr)))
312315
}
313316
});

0 commit comments

Comments
 (0)