diff --git a/qbittorrent-web-api-gen/src/generate/group/method/method_without_params.rs b/qbittorrent-web-api-gen/src/generate/group/method/method_without_params.rs index 3f91f7f..185b023 100644 --- a/qbittorrent-web-api-gen/src/generate/group/method/method_without_params.rs +++ b/qbittorrent-web-api-gen/src/generate/group/method/method_without_params.rs @@ -9,42 +9,39 @@ pub fn create_method_without_params( method_name: proc_macro2::Ident, url: &str, ) -> (proc_macro2::TokenStream, Option) { - match create_return_type(group, method) { + let res = match create_return_type(group, method) { Some((return_type_name, return_type)) => ( - util::add_docs( - &method.description, - quote! { - pub async fn #method_name(&self) -> Result<#return_type_name> { - let res = self.auth - .authenticated_client(#url) - .send() - .await? - .json::<#return_type_name>() - .await?; + quote! { + pub async fn #method_name(&self) -> Result<#return_type_name> { + let res = self.auth + .authenticated_client(#url) + .send() + .await? + .json::<#return_type_name>() + .await?; - Ok(res) - } - }, - ), + Ok(res) + } + }, Some(return_type), ), None => ( - util::add_docs( - &method.description, - quote! { - pub async fn #method_name(&self) -> Result { - let res = self.auth - .authenticated_client(#url) - .send() - .await? - .text() - .await?; + quote! { + pub async fn #method_name(&self) -> Result { + let res = self.auth + .authenticated_client(#url) + .send() + .await? + .text() + .await?; - Ok(res) - } - }, - ), // assume that all methods without a return type returns a string + Ok(res) + } + }, + // assume that all methods without a return type returns a string None, ), - } + }; + + (util::add_docs(&method.description, res.0), res.1) }