From 67c385cd2d91764eea9b514f108338091b302b95 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Sat, 26 Feb 2022 14:27:18 +0100 Subject: [PATCH] axum-macros: use fully qualified Result type (#796) --- axum-macros/src/typed_path.rs | 6 +++--- axum-macros/tests/typed_path/pass/tuple_struct.rs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/axum-macros/src/typed_path.rs b/axum-macros/src/typed_path.rs index d7b1414f..bb3fd48d 100644 --- a/axum-macros/src/typed_path.rs +++ b/axum-macros/src/typed_path.rs @@ -97,7 +97,7 @@ fn expand_named_fields(ident: &syn::Ident, path: LitStr, segments: &[Segment]) - { type Rejection = <::axum::extract::Path as ::axum::extract::FromRequest>::Rejection; - async fn from_request(req: &mut ::axum::extract::RequestParts) -> Result { + async fn from_request(req: &mut ::axum::extract::RequestParts) -> ::std::result::Result { ::axum::extract::Path::from_request(req).await.map(|path| path.0) } } @@ -186,7 +186,7 @@ fn expand_unnamed_fields( { type Rejection = <::axum::extract::Path as ::axum::extract::FromRequest>::Rejection; - async fn from_request(req: &mut ::axum::extract::RequestParts) -> Result { + async fn from_request(req: &mut ::axum::extract::RequestParts) -> ::std::result::Result { ::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) -> Result { + async fn from_request(req: &mut ::axum::extract::RequestParts) -> ::std::result::Result { if req.uri().path() == ::PATH { Ok(Self) } else { diff --git a/axum-macros/tests/typed_path/pass/tuple_struct.rs b/axum-macros/tests/typed_path/pass/tuple_struct.rs index a0b2e609..5e3d27ff 100644 --- a/axum-macros/tests/typed_path/pass/tuple_struct.rs +++ b/axum-macros/tests/typed_path/pass/tuple_struct.rs @@ -1,6 +1,8 @@ use axum_extra::routing::TypedPath; use serde::Deserialize; +pub type Result = std::result::Result; + #[derive(TypedPath, Deserialize)] #[typed_path("/users/:user_id/teams/:team_id")] struct MyPath(u32, u32);