Skip to content

Commit

Permalink
Merge pull request #25 from Goodjooy/master
Browse files Browse the repository at this point in the history
release 0.6.1
  • Loading branch information
Goodjooy authored Feb 15, 2024
2 parents eb423b4 + 2187c2b commit bc8c3be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pubilsh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
override: true

- name: Publish Macro
run: cargo publish -p axum-starter-macro --token ${CRATES_KEY}
run: cargo publish -p axum-resp-result-macro --token ${CRATES_KEY}

- name: Sleep for 60 seconds
if: success()
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
workspace = { members = ["code-gen"] }

[package]
name = "axum-resp-result"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
authors = ["FrozenString<[email protected]>"]
description = "Help Struct For Axum Response"
Expand Down Expand Up @@ -35,7 +36,7 @@ tracing-unwrap = { version = "0.10.0", features = [
"log-location",
], optional = true }
futures = "0.3"
axum-resp-result-macro = { version = "0.6.0" }
axum-resp-result-macro = { version = "0.6.1" }

[dependencies.serde]
version = "1"
Expand Down
2 changes: 1 addition & 1 deletion code-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "axum-resp-result-macro"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
authors = ["FrozenString<[email protected]>"]
description = "Help Struct For Axum Response"
Expand Down
11 changes: 10 additions & 1 deletion code-gen/src/ast_nodes/function_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct Function {
block: Box<Block>,
args: Vec<syn::Ident>,
inner_ident: syn::Ident,
is_async: bool,
}

impl ToTokens for Function {
Expand All @@ -24,16 +25,22 @@ impl ToTokens for Function {
outer_sig,
args,
inner_ident,
is_async,
} = self;

let ay = if *is_async {
Some(quote!(.await))
} else {
None
};
let inner = quote!(#inner_sig #block);
let outer = quote! {
#(#attrs)*
#vis #outer_sig
{
#inner

let __tmp = #inner_ident(#(#args),*);
let __tmp = #inner_ident(#(#args),*)#ay;
let __tmp = ::axum_resp_result::Fallible::to_result(__tmp);
::axum_resp_result::IntoRespResult::into_rresult(__tmp)
}
Expand Down Expand Up @@ -77,6 +84,7 @@ impl Parse for Function {
};

let new_ret = syn::parse::<ReturnType>(quote!(-> #new_ret).into())?;
let is_async = inner_sig.asyncness.is_some();
outer_sig.output = new_ret;

let mut args = Vec::new();
Expand Down Expand Up @@ -113,6 +121,7 @@ impl Parse for Function {
outer_sig,
args,
inner_ident,
is_async,
})
}
}

0 comments on commit bc8c3be

Please sign in to comment.