mirror of
https://github.com/tokio-rs/axum.git
synced 2025-01-01 08:56:15 +01:00
axum-macros: use fully qualified Result type (#796)
This commit is contained in:
parent
8175b9108f
commit
67c385cd2d
2 changed files with 5 additions and 3 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue