From 0f09415469843eea4000dc48085101dcf8d75e9b Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Mon, 7 Oct 2019 08:29:11 +0300 Subject: [PATCH] Convert documentation examples to Rust 2018 edition (#1120) * Convert types::query examples to rust-2018 edition * Convert types::json examples to rust-2018 edition * Convert types::path examples to rust-2018 edition * Convert types::form examples to rust-2018 edition * Convert rest of the examples to rust-2018 edition. --- src/extract.rs | 4 ++-- src/request.rs | 2 +- src/route.rs | 4 ++-- src/types/form.rs | 13 ++++++------- src/types/json.rs | 12 ++++++------ src/types/path.rs | 7 +++---- src/types/query.rs | 6 +++--- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/extract.rs b/src/extract.rs index 1687973a..42563731 100644 --- a/src/extract.rs +++ b/src/extract.rs @@ -46,9 +46,9 @@ pub trait FromRequest: Sized { /// ## Example /// /// ```rust -/// # #[macro_use] extern crate serde_derive; /// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest}; /// use actix_web::error::ErrorBadRequest; +/// use serde_derive::Deserialize; /// use rand; /// /// #[derive(Debug, Deserialize)] @@ -119,9 +119,9 @@ where /// ## Example /// /// ```rust -/// # #[macro_use] extern crate serde_derive; /// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest}; /// use actix_web::error::ErrorBadRequest; +/// use serde_derive::Deserialize; /// use rand; /// /// #[derive(Debug, Deserialize)] diff --git a/src/request.rs b/src/request.rs index 6d9d26e8..ea27e303 100644 --- a/src/request.rs +++ b/src/request.rs @@ -271,8 +271,8 @@ impl Drop for HttpRequest { /// ## Example /// /// ```rust -/// # #[macro_use] extern crate serde_derive; /// use actix_web::{web, App, HttpRequest}; +/// use serde_derive::Deserialize; /// /// /// extract `Thing` from request /// fn index(req: HttpRequest) -> String { diff --git a/src/route.rs b/src/route.rs index f4d30363..35b84294 100644 --- a/src/route.rs +++ b/src/route.rs @@ -178,8 +178,8 @@ impl Route { /// Set handler function, use request extractors for parameters. /// /// ```rust - /// #[macro_use] extern crate serde_derive; /// use actix_web::{web, http, App}; + /// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { @@ -239,9 +239,9 @@ impl Route { /// /// ```rust /// # use futures::future::ok; - /// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App, Error}; /// use futures::Future; + /// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { diff --git a/src/types/form.rs b/src/types/form.rs index 3bc067ab..c727ce0e 100644 --- a/src/types/form.rs +++ b/src/types/form.rs @@ -35,9 +35,8 @@ use crate::responder::Responder; /// /// ### Example /// ```rust -/// # extern crate actix_web; -/// #[macro_use] extern crate serde_derive; -/// use actix_web::{web, App}; +/// use actix_web::web; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct FormData { @@ -61,9 +60,9 @@ use crate::responder::Responder; /// /// ### Example /// ```rust -/// # #[macro_use] extern crate serde_derive; -/// # use actix_web::*; -/// # +/// use actix_web::*; +/// use serde_derive::Serialize; +/// /// #[derive(Serialize)] /// struct SomeForm { /// name: String, @@ -167,8 +166,8 @@ impl Responder for Form { /// Form extractor configuration /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App, FromRequest, Result}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct FormData { diff --git a/src/types/json.rs b/src/types/json.rs index f309a3c5..e80d0a45 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -33,8 +33,8 @@ use crate::responder::Responder; /// ## Example /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { @@ -60,9 +60,9 @@ use crate::responder::Responder; /// trait from *serde*. /// /// ```rust -/// # #[macro_use] extern crate serde_derive; -/// # use actix_web::*; -/// # +/// use actix_web::*; +/// use serde_derive::Serialize; +/// /// #[derive(Serialize)] /// struct MyObj { /// name: String, @@ -144,8 +144,8 @@ impl Responder for Json { /// ## Example /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { @@ -203,8 +203,8 @@ where /// Json extractor configuration /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{error, web, App, FromRequest, HttpResponse}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { diff --git a/src/types/path.rs b/src/types/path.rs index a4657576..fa7c6e11 100644 --- a/src/types/path.rs +++ b/src/types/path.rs @@ -39,8 +39,8 @@ use crate::FromRequest; /// implements `Deserialize` trait from *serde*. /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App, Error}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { @@ -134,8 +134,8 @@ impl fmt::Display for Path { /// implements `Deserialize` trait from *serde*. /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App, Error}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info { @@ -190,10 +190,9 @@ where /// Path extractor configuration /// /// ```rust -/// # #[macro_use] -/// # extern crate serde_derive; /// use actix_web::web::PathConfig; /// use actix_web::{error, web, App, FromRequest, HttpResponse}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize, Debug)] /// enum Folder { diff --git a/src/types/query.rs b/src/types/query.rs index 60b07085..817b2ed7 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -21,8 +21,8 @@ use crate::request::HttpRequest; /// ## Example /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App}; +/// use serde_derive::Deserialize; /// /// #[derive(Debug, Deserialize)] /// pub enum ResponseType { @@ -99,8 +99,8 @@ impl fmt::Display for Query { /// ## Example /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{web, App}; +/// use serde_derive::Deserialize; /// /// #[derive(Debug, Deserialize)] /// pub enum ResponseType { @@ -169,8 +169,8 @@ where /// ## Example /// /// ```rust -/// #[macro_use] extern crate serde_derive; /// use actix_web::{error, web, App, FromRequest, HttpResponse}; +/// use serde_derive::Deserialize; /// /// #[derive(Deserialize)] /// struct Info {