Simplify borrow building
This commit is contained in:
parent
499f60266a
commit
934868df42
|
@ -63,23 +63,21 @@ pub fn create_method_with_params(
|
|||
let name = util::to_ident(&n.to_snake());
|
||||
let t = util::to_ident(¶m.to_borrowed_type());
|
||||
|
||||
let method = if param.should_borrow() {
|
||||
quote! {
|
||||
pub fn #name(mut self, value: &#t) -> Self {
|
||||
self.form = self.form.text(#n, value.to_string());
|
||||
self
|
||||
}
|
||||
}
|
||||
let builder_param = if param.should_borrow() {
|
||||
quote! { &#t }
|
||||
} else {
|
||||
quote! {
|
||||
pub fn #name(mut self, value: #t) -> Self {
|
||||
self.form = self.form.text(#n, value.to_string());
|
||||
self
|
||||
}
|
||||
}
|
||||
quote! { #t }
|
||||
};
|
||||
|
||||
util::add_docs(¶m.get_type_info().description, method)
|
||||
util::add_docs(
|
||||
¶m.get_type_info().description,
|
||||
quote! {
|
||||
pub fn #name(mut self, value: #builder_param) -> Self {
|
||||
self.form = self.form.text(#n, value.to_string());
|
||||
self
|
||||
}
|
||||
},
|
||||
)
|
||||
});
|
||||
|
||||
let group_name = util::to_ident(&group.name.to_camel());
|
||||
|
|
Loading…
Reference in New Issue
Block a user