mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-23 04:52:28 +00:00
we need to clone the AuthSource because lifetimes are annoying
This commit is contained in:
parent
747c0063c4
commit
d3b27bae8a
1 changed files with 4 additions and 3 deletions
|
@ -244,8 +244,8 @@ pub fn expand_method(method : Method, attrs : TokenStream, item : TokenStream) -
|
||||||
(MethodArgumentType::StateMutRef, _) => quote!(#state_ident),
|
(MethodArgumentType::StateMutRef, _) => quote!(#state_ident),
|
||||||
(MethodArgumentType::MethodArg(_), ident) => quote!(#ident),
|
(MethodArgumentType::MethodArg(_), ident) => quote!(#ident),
|
||||||
(MethodArgumentType::DatabaseConnection(_), _) => quote!(&#conn_ident),
|
(MethodArgumentType::DatabaseConnection(_), _) => quote!(&#conn_ident),
|
||||||
(MethodArgumentType::AuthStatus(_), _) => quote!(#auth_ident.clone()),
|
(MethodArgumentType::AuthStatus(_), _) => quote!(#auth_ident),
|
||||||
(MethodArgumentType::AuthStatusRef(_), _) => quote!(#auth_ident)
|
(MethodArgumentType::AuthStatusRef(_), _) => quote!(&#auth_ident)
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// prepare the method block
|
// prepare the method block
|
||||||
|
@ -268,7 +268,7 @@ pub fn expand_method(method : Method, attrs : TokenStream, item : TokenStream) -
|
||||||
{
|
{
|
||||||
let auth_ty = arg.ty.quote_ty();
|
let auth_ty = arg.ty.quote_ty();
|
||||||
block = quote! {
|
block = quote! {
|
||||||
let #auth_ident : &#auth_ty = <#auth_ty>::borrow_from(#state_ident);
|
let #auth_ident : #auth_ty = <#auth_ty>::borrow_from(#state_ident).clone();
|
||||||
#block
|
#block
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -303,5 +303,6 @@ pub fn expand_method(method : Method, attrs : TokenStream, item : TokenStream) -
|
||||||
route.#method_ident::<#resource_ident, #(#generics),*>();
|
route.#method_ident::<#resource_ident, #(#generics),*>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
eprintln!("{}", output);
|
||||||
output.into()
|
output.into()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue