From 9a74dafc76752e2bc9d373b6979ba34ee6a13b63 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 10 Aug 2022 10:28:23 +0200 Subject: [PATCH] Expose inner value of Path The inner value is already exposed via the `into_inner` function, so we may as well expose it directly to improve ergonomics. I have updated the doc example to illustrate this. Note that this aligns the implementation with that of Query, Json, Header, and Form. --- actix-web/src/types/path.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/actix-web/src/types/path.rs b/actix-web/src/types/path.rs index a90c912f6..8da8dcbde 100644 --- a/actix-web/src/types/path.rs +++ b/actix-web/src/types/path.rs @@ -29,8 +29,7 @@ use crate::{ /// // {name} - deserialize a String /// // {count} - deserialize a u32 /// #[get("/{name}/{count}/index.html")] -/// async fn index(path: web::Path<(String, u32)>) -> String { -/// let (name, count) = path.into_inner(); +/// async fn index(web::Path((name, count)): web::Path<(String, u32)>) -> String { /// format!("Welcome {}! {}", name, count) /// } /// ``` @@ -54,7 +53,7 @@ use crate::{ /// } /// ``` #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Deref, DerefMut, AsRef, Display, From)] -pub struct Path(T); +pub struct Path(pub T); impl Path { /// Unwrap into inner `T` value.