From d7a0715188e2a6cdff70959c11e929bfaf5ffe45 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Tue, 1 Jun 2021 15:12:22 +0200 Subject: [PATCH] Update readme --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb0821aa..0fd49595 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,8 @@ async fn handler( // deserialize query string into a `Pagination` pagination: extract::Query, ) -> &'static str { - let user: UserPayload = user.into_inner(); - let pagination: Pagination = pagination.into_inner(); + let user: UserPayload = user.0; + let pagination: Pagination = pagination.0; // ... } @@ -148,12 +148,24 @@ async fn handle( // or get a tuple with each param params: extract::UrlParams<(i32, String)>, ) -> &'static str { - let (id, name) = params.into_inner(); + let (id, name) = params.0; // ... } ``` +If you wanna go all out you can even deconstruct the extractor directly in the +function signature: + +```rust +async fn handle( + req: Request, + UrlParams((id, name)): UrlParams<(i32, String)>, +) -> &'static str { + // ... +} +``` + Anything that implements `FromRequest` can work as an extractor where `FromRequest` is an async trait: