setter through Into-types does not seem to work
Closed this issue · 3 comments
mismosmi commented
Hi,
Sorry if I'm just a bit confused whether this is intended:
I'm trying to use setters with string literals for string-type fields
#[derive(TypedBuilder)]
struct MyStruct {
text: String
}
MyStruct::builder().text("abc").build()
and get a mismatched type errors. If I understand the readme correctly this should work, right?
mismosmi commented
I'm still a bit of a beginner but I guess I could write and send you a fix for this myself if you don't have time for it, just asking if it's intended.
idanarye commented
Yes, this is intended - the readme is out of date. It was a breaking change in version 0.5.0.
This should work:
#[derive(TypedBuilder)]
struct MyStruct {
#[builder(setter(into))]
text: String
}
MyStruct::builder().text("abc").build()
mismosmi commented
Ah great, thanks!