From e7c34f2e45125d00c899994473212703731fd605 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 25 Nov 2022 21:38:36 +0000 Subject: [PATCH] tweak form docs --- actix-web/src/types/form.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/actix-web/src/types/form.rs b/actix-web/src/types/form.rs index 9c09c6b73..d73f8ba74 100644 --- a/actix-web/src/types/form.rs +++ b/actix-web/src/types/form.rs @@ -35,6 +35,7 @@ use crate::{ /// /// Use [`FormConfig`] to configure extraction options. /// +/// ## Examples /// ``` /// use actix_web::{post, web}; /// use serde::Deserialize; @@ -46,20 +47,18 @@ use crate::{ /// /// // This handler is only called if: /// // - request headers declare the content type as `application/x-www-form-urlencoded` -/// // - request payload is deserialized into a `Info` struct from the URL encoded format +/// // - request payload deserializes into an `Info` struct from the URL encoded format /// #[post("/")] -/// async fn index(form: web::Form) -> String { +/// async fn index(web::Form(form): web::Form) -> String { /// format!("Welcome {}!", form.name) /// } /// ``` /// /// # Responder -/// The `Form` type also allows you to create URL encoded responses: -/// simply return a value of type Form where T is the type to be URL encoded. -/// The type must implement [`serde::Serialize`]. -/// -/// Responses use +/// The `Form` type also allows you to create URL encoded responses by returning a value of type +/// `Form` where `T` is the type to be URL encoded, as long as `T` implements [`Serialize`]. /// +/// ## Examples /// ``` /// use actix_web::{get, web}; /// use serde::Serialize; @@ -77,7 +76,7 @@ use crate::{ /// #[get("/")] /// async fn index() -> web::Form { /// web::Form(SomeForm { -/// name: "actix".into(), +/// name: "actix".to_owned(), /// age: 123 /// }) /// }