Skip to content

Commit

Permalink
fix: allow paths to ServerFnError type
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Jan 26, 2024
1 parent ca3806e commit ae83a02
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions server_fn_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,18 +637,20 @@ fn err_type(return_ty: &Type) -> Result<Option<&GenericArgument>> {
else if let GenericArgument::Type(Type::Path(pat)) =
&args.args[1]
{
if pat.path.segments[0].ident == "ServerFnError" {
let args = &pat.path.segments[0].arguments;
match args {
// Result<T, ServerFnError>
PathArguments::None => return Ok(None),
// Result<T, ServerFnError<E>>
PathArguments::AngleBracketed(args) => {
if args.args.len() == 1 {
return Ok(Some(&args.args[0]));
if let Some(segment) = pat.path.segments.last() {
if segment.ident == "ServerFnError" {
let args = &pat.path.segments[0].arguments;
match args {
// Result<T, ServerFnError>
PathArguments::None => return Ok(None),
// Result<T, ServerFnError<E>>
PathArguments::AngleBracketed(args) => {
if args.args.len() == 1 {
return Ok(Some(&args.args[0]));
}
}
_ => {}
}
_ => {}
}
}
}
Expand Down

0 comments on commit ae83a02

Please sign in to comment.