mirror of https://github.com/fafhrd91/actix-web
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.
This commit is contained in:
parent
ea764b1d57
commit
9a74dafc76
|
@ -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>(T);
|
||||
pub struct Path<T>(pub T);
|
||||
|
||||
impl<T> Path<T> {
|
||||
/// Unwrap into inner `T` value.
|
||||
|
|
Loading…
Reference in New Issue