axum-macros: use fully qualified Result type (#796)

This commit is contained in:
Matthias Vogelgesang 2022-02-26 14:27:18 +01:00 committed by GitHub
parent 8175b9108f
commit 67c385cd2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -97,7 +97,7 @@ fn expand_named_fields(ident: &syn::Ident, path: LitStr, segments: &[Segment]) -
{ {
type Rejection = <::axum::extract::Path<Self> as ::axum::extract::FromRequest<B>>::Rejection; type Rejection = <::axum::extract::Path<Self> as ::axum::extract::FromRequest<B>>::Rejection;
async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> Result<Self, Self::Rejection> { async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> ::std::result::Result<Self, Self::Rejection> {
::axum::extract::Path::from_request(req).await.map(|path| path.0) ::axum::extract::Path::from_request(req).await.map(|path| path.0)
} }
} }
@ -186,7 +186,7 @@ fn expand_unnamed_fields(
{ {
type Rejection = <::axum::extract::Path<Self> as ::axum::extract::FromRequest<B>>::Rejection; type Rejection = <::axum::extract::Path<Self> as ::axum::extract::FromRequest<B>>::Rejection;
async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> Result<Self, Self::Rejection> { async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> ::std::result::Result<Self, Self::Rejection> {
::axum::extract::Path::from_request(req).await.map(|path| path.0) ::axum::extract::Path::from_request(req).await.map(|path| path.0)
} }
} }
@ -245,7 +245,7 @@ fn expand_unit_fields(ident: &syn::Ident, path: LitStr) -> syn::Result<TokenStre
{ {
type Rejection = ::axum::http::StatusCode; type Rejection = ::axum::http::StatusCode;
async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> Result<Self, Self::Rejection> { async fn from_request(req: &mut ::axum::extract::RequestParts<B>) -> ::std::result::Result<Self, Self::Rejection> {
if req.uri().path() == <Self as ::axum_extra::routing::TypedPath>::PATH { if req.uri().path() == <Self as ::axum_extra::routing::TypedPath>::PATH {
Ok(Self) Ok(Self)
} else { } else {

View file

@ -1,6 +1,8 @@
use axum_extra::routing::TypedPath; use axum_extra::routing::TypedPath;
use serde::Deserialize; use serde::Deserialize;
pub type Result<T> = std::result::Result<T, ()>;
#[derive(TypedPath, Deserialize)] #[derive(TypedPath, Deserialize)]
#[typed_path("/users/:user_id/teams/:team_id")] #[typed_path("/users/:user_id/teams/:team_id")]
struct MyPath(u32, u32); struct MyPath(u32, u32);