Update many doc tests in 'core' for async.

This commit is contained in:
Jeb Rosen 2019-08-06 17:08:00 -07:00
parent 4354ebc6ab
commit 0fb3b8f584
49 changed files with 162 additions and 136 deletions

View File

@ -50,7 +50,7 @@
//! In your application's source code, one-time:
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//!
//! #[macro_use] extern crate rocket;
//! #[macro_use] extern crate rocket_contrib;

View File

@ -42,7 +42,7 @@ pub use self::uuid_crate::parser::ParseError;
/// You can use the `Uuid` type directly as a target of a dynamic parameter:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # #[macro_use] extern crate rocket_contrib;
/// use rocket_contrib::uuid::Uuid;
@ -56,7 +56,7 @@ pub use self::uuid_crate::parser::ParseError;
/// You can also use the `Uuid` as a form value, including in query strings:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # #[macro_use] extern crate rocket_contrib;
/// use rocket_contrib::uuid::Uuid;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use]
#[cfg(all(feature = "brotli_compression", feature = "gzip_compression"))]

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use]
#[cfg(all(feature = "brotli_compression", feature = "gzip_compression"))]

View File

@ -30,7 +30,7 @@
//! crate root:
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//!
//! #[macro_use] extern crate rocket;
//! # #[get("/")] fn hello() { }
@ -40,7 +40,7 @@
//! Or, alternatively, selectively import from the top-level scope:
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//! # extern crate rocket;
//!
//! use rocket::{get, routes};
@ -147,7 +147,7 @@ macro_rules! route_attribute {
/// functions:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[get("/")]
@ -170,7 +170,7 @@ macro_rules! route_attribute {
/// explicitly specified:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[route(GET, path = "/")]
@ -231,7 +231,7 @@ macro_rules! route_attribute {
/// the arguments `foo`, `baz`, `msg`, `rest`, and `form`:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::request::Form;
/// # use std::path::PathBuf;
@ -343,7 +343,7 @@ route_attribute!(options => Method::Options);
/// This attribute can only be applied to free functions:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// use rocket::Request;
@ -755,7 +755,7 @@ pub fn derive_uri_display_path(input: TokenStream) -> TokenStream {
/// corresponding [`Route`] structures. For example, given the following routes:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[get("/")]
@ -770,7 +770,7 @@ pub fn derive_uri_display_path(input: TokenStream) -> TokenStream {
/// The `routes!` macro can be used as:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # use rocket::http::Method;
@ -814,7 +814,7 @@ pub fn routes(input: TokenStream) -> TokenStream {
/// catchers:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[catch(404)]
@ -829,7 +829,7 @@ pub fn routes(input: TokenStream) -> TokenStream {
/// The `catchers!` macro can be used as:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # #[catch(404)] fn not_found() { /* .. */ }
@ -871,7 +871,7 @@ pub fn catchers(input: TokenStream) -> TokenStream {
/// For example, for the following route:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[get("/person/<name>?<age>")]
@ -885,7 +885,7 @@ pub fn catchers(input: TokenStream) -> TokenStream {
/// A URI can be created as follows:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # #[get("/person/<name>?<age>")]

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
use rocket::local::Client;
use rocket::response::Responder;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#![allow(dead_code, unused_variables)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,6 +1,6 @@
// must-compile-successfully
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,7 +1,7 @@
// normalize-stderr-test: "<(.*) as (.*)>" -> "$1 as $$TRAIT"
// normalize-stderr-test: "and \d+ others" -> "and $$N others"
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -53,7 +53,7 @@ mod key {
/// a handler to retrieve the value of a "message" cookie.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::http::Cookies;
///
@ -73,7 +73,7 @@ mod key {
/// [private cookie]: Cookies::add_private()
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// use rocket::http::Status;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#![recursion_limit="512"]
#![warn(rust_2018_idioms)]

View File

@ -155,7 +155,7 @@ use crate::uri::{self, UriPart, UriDisplay};
/// With these implementations, the following typechecks:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # use std::fmt;
/// use rocket::http::RawStr;

View File

@ -61,7 +61,7 @@ use crate::uri::{Uri, UriPart, Path, Query, Formatter};
/// the following route:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #[get("/item/<id>?<track>")]
/// fn get_item(id: i32, track: Option<String>) { /* .. */ }
@ -70,7 +70,7 @@ use crate::uri::{Uri, UriPart, Path, Query, Formatter};
/// A URI for this route can be generated as follows:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # type T = ();
/// # #[get("/item/<id>?<track>")]
@ -234,7 +234,7 @@ use crate::uri::{Uri, UriPart, Path, Query, Formatter};
/// `UriDisplay` implementation is required.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::http::RawStr;
/// use rocket::request::FromParam;
@ -432,7 +432,7 @@ impl<T: UriDisplay<Query>, E> UriDisplay<Query> for Result<T, E> {
/// trait for the corresponding `UriPart`.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #[get("/item/<id>?<track>")]
/// fn get_item(id: i32, track: Option<u8>) { /* .. */ }

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
#[macro_use] extern crate rocket;

View File

@ -1,4 +1,4 @@
#![feature(proc_macro_hygiene)]
#![feature(proc_macro_hygiene, async_await)]
// #![feature(alloc_system)]
// extern crate alloc_system;

View File

@ -36,7 +36,7 @@ use yansi::Color::*;
/// declared using the `catch` decorator, as follows:
///
/// ```rust
/// #![feature(proc_macro_hygiene)]
/// #![feature(proc_macro_hygiene, async_await)]
///
/// #[macro_use] extern crate rocket;
///
@ -78,16 +78,17 @@ impl Catcher {
/// ```rust
/// # #![allow(unused_variables)]
/// use rocket::{Catcher, Request};
/// use rocket::handler::ErrorHandlerFuture;
/// use rocket::response::{Result, Responder};
/// use rocket::response::status::Custom;
/// use rocket::http::Status;
///
/// fn handle_404<'r>(req: &'r Request) -> Result<'r> {
/// fn handle_404<'r>(req: &'r Request) -> ErrorHandlerFuture<'r> {
/// let res = Custom(Status::NotFound, format!("404: {}", req.uri()));
/// res.respond_to(req)
/// }
///
/// fn handle_500<'r>(req: &'r Request) -> Result<'r> {
/// fn handle_500<'r>(req: &'r Request) -> ErrorHandlerFuture<'r> {
/// "Whoops, we messed up!".respond_to(req)
/// }
///

View File

@ -23,7 +23,7 @@ const PEEK_BYTES: usize = 512;
/// specifying the `data = "<var>"` route parameter as follows:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # type DataGuard = rocket::data::Data;
/// #[post("/submit", data = "<var>")]

View File

@ -117,12 +117,15 @@ impl AdHoc {
/// # Example
///
/// ```rust
/// # #![feature(async_await)]
/// use rocket::fairing::AdHoc;
///
/// // The no-op response fairing.
/// let fairing = AdHoc::on_response("Dummy", |req, resp| {
/// Box::pin(async move {
/// // do something with the request and pending response...
/// # let (_, _) = (req, resp);
/// })
/// });
/// ```
pub fn on_response<F>(name: &'static str, f: F) -> AdHoc

View File

@ -20,9 +20,10 @@
//! write:
//!
//! ```rust
//! # #![feature(async_await)]
//! # use rocket::fairing::AdHoc;
//! # let req_fairing = AdHoc::on_request("Request", |_, _| ());
//! # let res_fairing = AdHoc::on_response("Response", |_, _| ());
//! # let res_fairing = AdHoc::on_response("Response", |_, _| Box::pin(async move {}));
//! let rocket = rocket::ignite()
//! .attach(req_fairing)
//! .attach(res_fairing);
@ -206,7 +207,10 @@ pub use self::info_kind::{Info, Kind};
/// path.
///
/// ```rust
/// # #![feature(async_await)]
/// use std::future::Future;
/// use std::io::Cursor;
/// use std::pin::Pin;
/// use std::sync::atomic::{AtomicUsize, Ordering};
///
/// use rocket::{Request, Data, Response};
@ -235,7 +239,8 @@ pub use self::info_kind::{Info, Kind};
/// }
/// }
///
/// fn on_response(&self, request: &Request, response: &mut Response) {
/// fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> {
/// Box::pin(async move {
/// // Don't change a successful user's response, ever.
/// if response.status() != Status::NotFound {
/// return
@ -250,6 +255,7 @@ pub use self::info_kind::{Info, Kind};
/// response.set_header(ContentType::Plain);
/// response.set_sized_body(Cursor::new(body));
/// }
/// })
/// }
/// }
/// ```
@ -265,6 +271,9 @@ pub use self::info_kind::{Info, Kind};
/// request guard.
///
/// ```rust
/// # #![feature(async_await)]
/// # use std::future::Future;
/// # use std::pin::Pin;
/// # use std::time::{Duration, SystemTime};
/// # use rocket::Outcome;
/// # use rocket::{Request, Data, Response};
@ -297,12 +306,14 @@ pub use self::info_kind::{Info, Kind};
///
/// /// Adds a header to the response indicating how long the server took to
/// /// process the request.
/// fn on_response(&self, request: &Request, response: &mut Response) {
/// fn on_response<'a, 'r>(&'a self, request: &'a Request<'r>, response: &'a mut Response<'r>) -> Pin<Box<dyn Future<Output=()> + Send + 'a>> {
/// Box::pin(async move {
/// let start_time = request.local_cache(|| TimerStart(None));
/// if let Some(Ok(duration)) = start_time.0.map(|st| st.elapsed()) {
/// let ms = duration.as_secs() * 1000 + duration.subsec_millis() as u64;
/// response.set_raw_header("X-Response-Time", format!("{} ms", ms));
/// }
/// })
/// }
/// }
///

View File

@ -42,15 +42,16 @@ pub type HandlerFuture<'r> = std::pin::Pin<Box<dyn Future<Output = Outcome<'r>>
/// Such a handler might be written and used as follows:
///
/// ```rust
/// # #![feature(async_await)]
/// # #[derive(Copy, Clone)] enum Kind { Simple, Intermediate, Complex, }
/// use rocket::{Request, Data, Route, http::Method};
/// use rocket::handler::{self, Handler, Outcome};
/// use rocket::handler::{self, Handler, Outcome, HandlerFuture};
///
/// #[derive(Clone)]
/// struct CustomHandler(Kind);
///
/// impl Handler for CustomHandler {
/// fn handle<'r>(&self, req: &'r Request, data: Data) -> Outcome<'r> {
/// fn handle<'r>(&self, req: &'r Request, data: Data) -> HandlerFuture<'r> {
/// match self.0 {
/// Kind::Simple => Outcome::from(req, "simple"),
/// Kind::Intermediate => Outcome::from(req, "intermediate"),
@ -91,7 +92,7 @@ pub type HandlerFuture<'r> = std::pin::Pin<Box<dyn Future<Output = Outcome<'r>>
/// managed state and a static route, as follows:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # #[derive(Copy, Clone)]
@ -198,10 +199,11 @@ impl<'r> Outcome<'r> {
/// # Example
///
/// ```rust
/// # #![feature(async_await)]
/// use rocket::{Request, Data};
/// use rocket::handler::Outcome;
/// use rocket::handler::{Outcome, HandlerFuture};
///
/// fn str_responder(req: &Request, _: Data) -> Outcome<'static> {
/// fn str_responder<'r>(req: &'r Request, _: Data) -> HandlerFuture<'r> {
/// Outcome::from(req, "Hello, world!")
/// }
/// ```
@ -253,10 +255,11 @@ impl<'r> Outcome<'r> {
/// # Example
///
/// ```rust
/// # #![feature(async_await)]
/// use rocket::{Request, Data};
/// use rocket::handler::Outcome;
/// use rocket::handler::{Outcome, HandlerFuture};
///
/// fn str_responder(req: &Request, data: Data) -> Outcome<'static> {
/// fn str_responder<'r>(req: &'r Request, data: Data) -> HandlerFuture<'r> {
/// Outcome::from_or_forward(req, data, "Hello, world!")
/// }
/// ```
@ -281,12 +284,15 @@ impl<'r> Outcome<'r> {
/// # Example
///
/// ```rust
/// # #![feature(async_await)]
/// use rocket::{Request, Data};
/// use rocket::handler::Outcome;
/// use rocket::handler::{Outcome, HandlerFuture};
/// use rocket::http::Status;
///
/// fn bad_req_route(_: &Request, _: Data) -> Outcome<'static> {
/// fn bad_req_route<'r>(_: &'r Request, _: Data) -> HandlerFuture<'r> {
/// Box::pin(async move {
/// Outcome::failure(Status::BadRequest)
/// })
/// }
/// ```
#[inline(always)]
@ -303,11 +309,14 @@ impl<'r> Outcome<'r> {
/// # Example
///
/// ```rust
/// # #![feature(async_await)]
/// use rocket::{Request, Data};
/// use rocket::handler::Outcome;
/// use rocket::handler::{Outcome, HandlerFuture};
///
/// fn always_forward(_: &Request, data: Data) -> Outcome<'static> {
/// fn always_forward<'r>(_: &'r Request, data: Data) -> HandlerFuture<'r> {
/// Box::pin(async move {
/// Outcome::forward(data)
/// })
/// }
/// ```
#[inline(always)]

View File

@ -48,7 +48,7 @@
//! Then, add the following to the top of your `main.rs` file:
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//!
//! #[macro_use] extern crate rocket;
//! # #[get("/")] fn hello() { }
@ -59,7 +59,7 @@
//! write Rocket applications. Here's a simple example to get you started:
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//!
//! #[macro_use] extern crate rocket;
//!

View File

@ -67,7 +67,7 @@
//! consider the following complete "Hello, world!" application, with testing.
//!
//! ```rust
//! #![feature(proc_macro_hygiene)]
//! #![feature(proc_macro_hygiene, async_await)]
//!
//! #[macro_use] extern crate rocket;
//!

View File

@ -50,7 +50,7 @@ pub enum FormDataError<'f, E> {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::{Form, FormError, FormDataError};
///

View File

@ -33,7 +33,7 @@ use crate::ext::AsyncReadExt as _;
/// implements the `FromForm` trait:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::Form;
/// use rocket::http::RawStr;
@ -69,7 +69,7 @@ use crate::ext::AsyncReadExt as _;
/// A handler that handles a form of this type can similarly by written:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #![allow(deprecated, unused_attributes)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::request::Form;
@ -122,7 +122,7 @@ impl<T> Form<T> {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::Form;
///

View File

@ -13,7 +13,7 @@ use crate::request::FormItems;
/// validation.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #![allow(deprecated, dead_code, unused_attributes)]
/// # #[macro_use] extern crate rocket;
/// #[derive(FromForm)]
@ -30,7 +30,7 @@ use crate::request::FormItems;
/// data via the `data` parameter and `Form` type.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #![allow(deprecated, dead_code, unused_attributes)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::request::Form;

View File

@ -43,7 +43,7 @@ use crate::http::RawStr;
/// according to its target type:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # type Size = String;
/// #[get("/item?<id>&<size>")]

View File

@ -31,7 +31,7 @@ use crate::http::uri::{Query, FromUriParam};
/// handler:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::LenientForm;
///
@ -67,7 +67,7 @@ impl<T> LenientForm<T> {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::LenientForm;
///

View File

@ -55,7 +55,7 @@ impl<S, E> IntoOutcome<S, (Status, E), ()> for Result<S, E> {
/// guard.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::http::Method;
/// # type A = Method; type B = Method; type C = Method; type T = ();
@ -165,7 +165,7 @@ impl<S, E> IntoOutcome<S, (Status, E), ()> for Result<S, E> {
/// `sensitive` handler.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// use rocket::Outcome;
@ -220,7 +220,7 @@ impl<S, E> IntoOutcome<S, (Status, E), ()> for Result<S, E> {
/// routes (`admin_dashboard` and `user_dashboard`):
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # #[cfg(feature = "private-cookies")] mod inner {
/// # use rocket::outcome::{IntoOutcome, Outcome};
@ -283,7 +283,7 @@ impl<S, E> IntoOutcome<S, (Status, E), ()> for Result<S, E> {
/// used, as illustrated below:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # #[cfg(feature = "private-cookies")] mod inner {
/// # use rocket::outcome::{IntoOutcome, Outcome};

View File

@ -19,7 +19,7 @@ use crate::http::{RawStr, uri::{Segments, SegmentError}};
/// handler for the dynamic `"/<id>"` path:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #[get("/<id>")]
/// fn hello(id: usize) -> String {
@ -54,7 +54,7 @@ use crate::http::{RawStr, uri::{Segments, SegmentError}};
/// parameter as follows:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::http::RawStr;
/// #[get("/<id>")]
@ -172,7 +172,7 @@ use crate::http::{RawStr, uri::{Segments, SegmentError}};
/// dynamic path segment:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # use rocket::request::FromParam;
/// # use rocket::http::RawStr;

View File

@ -8,7 +8,7 @@ use crate::request::{FormItems, FormItem, Form, LenientForm, FromForm};
/// generation for every trailing query parameter, `<params..>` below:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # use rocket::request::Form;
@ -82,7 +82,7 @@ impl<'q> Iterator for Query<'q> {
/// route:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::request::Form;
///

View File

@ -22,7 +22,7 @@ use crate::http::Status;
/// following example does just this:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::State;
///
@ -87,7 +87,7 @@ use crate::http::Status;
/// [`State::from()`] static method:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::State;
///

View File

@ -45,7 +45,7 @@ const FLASH_COOKIE_NAME: &str = "_flash";
/// message on both the request and response sides.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::response::{Flash, Redirect};
/// use rocket::request::FlashMessage;

View File

@ -26,7 +26,7 @@ use crate::http::Status;
/// a route, _always_ use [`uri!`] to construct a valid [`Origin`]:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::response::Redirect;
///

View File

@ -13,7 +13,7 @@ use crate::request::Request;
/// as illustrated below with `T`:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// # type T = ();
/// #
@ -154,7 +154,7 @@ use crate::request::Request;
/// following `Responder` implementation accomplishes this:
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// # #[derive(Debug)]
@ -166,14 +166,16 @@ use crate::request::Request;
/// use rocket::response::{self, Response, Responder};
/// use rocket::http::ContentType;
///
/// impl Responder<'_> for Person {
/// fn respond_to(self, _: &Request) -> response::Result<'static> {
/// impl Responder<'r> for Person {
/// fn respond_to(self, _: &'r Request) -> response::ResultFuture<'r> {
/// Box::pin(async move {
/// Response::build()
/// .sized_body(Cursor::new(format!("{}:{}", self.name, self.age)))
/// .raw_header("X-Person-Name", self.name)
/// .raw_header("X-Person-Age", self.age.to_string())
/// .header(ContentType::new("application", "x-person"))
/// .ok()
/// })
/// }
/// }
/// #

View File

@ -513,7 +513,7 @@ impl Rocket {
/// dispatched to the `hi` route.
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// #
/// #[get("/world")]
@ -535,10 +535,10 @@ impl Rocket {
///
/// ```rust
/// use rocket::{Request, Route, Data};
/// use rocket::handler::Outcome;
/// use rocket::handler::{HandlerFuture, Outcome};
/// use rocket::http::Method::*;
///
/// fn hi<'r>(req: &'r Request, _: Data) -> Outcome<'r> {
/// fn hi<'r>(req: &'r Request, _: Data) -> HandlerFuture<'r> {
/// Outcome::from(req, "Hello!")
/// }
///
@ -585,7 +585,7 @@ impl Rocket {
/// # Examples
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::Request;
///
@ -641,7 +641,7 @@ impl Rocket {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::State;
///
@ -678,7 +678,7 @@ impl Rocket {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::Rocket;
/// use rocket::fairing::AdHoc;
@ -819,7 +819,7 @@ impl Rocket {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::Rocket;
/// use rocket::fairing::AdHoc;
@ -875,7 +875,7 @@ impl Rocket {
/// # Example
///
/// ```rust
/// # #![feature(proc_macro_hygiene)]
/// # #![feature(proc_macro_hygiene, async_await)]
/// # #[macro_use] extern crate rocket;
/// use rocket::Rocket;
/// use rocket::fairing::AdHoc;

View File

@ -108,8 +108,8 @@ impl Route {
/// use rocket::Route;
/// use rocket::http::Method;
/// # use rocket::{Request, Data};
/// # use rocket::handler::Outcome;
/// # fn handler<'r>(request: &'r Request, _data: Data) -> Outcome<'r> {
/// # use rocket::handler::{Outcome, HandlerFuture};
/// # fn handler<'r>(request: &'r Request, _data: Data) -> HandlerFuture<'r> {
/// # Outcome::from(request, "Hello, world!")
/// # }
///
@ -158,8 +158,8 @@ impl Route {
/// use rocket::Route;
/// use rocket::http::Method;
/// # use rocket::{Request, Data};
/// # use rocket::handler::Outcome;
/// # fn handler<'r>(request: &'r Request, _data: Data) -> Outcome<'r> {
/// # use rocket::handler::{Outcome, HandlerFuture};
/// # fn handler<'r>(request: &'r Request, _data: Data) -> HandlerFuture<'r> {
/// # Outcome::from(request, "Hello, world!")
/// # }
///
@ -208,9 +208,9 @@ impl Route {
/// use rocket::Route;
/// use rocket::http::Method;
/// # use rocket::{Request, Data};
/// # use rocket::handler::Outcome;
/// # use rocket::handler::{Outcome, HandlerFuture};
/// #
/// # fn handler<'r>(request: &'r Request, _data: Data) -> Outcome<'r> {
/// # fn handler<'r>(request: &'r Request, _data: Data) -> HandlerFuture<'r> {
/// # Outcome::from(request, "Hello, world!")
/// # }
///
@ -242,9 +242,9 @@ impl Route {
/// use rocket::Route;
/// use rocket::http::{Method, uri::Origin};
/// # use rocket::{Request, Data};
/// # use rocket::handler::Outcome;
/// # use rocket::handler::{Outcome, HandlerFuture};
/// #
/// # fn handler<'r>(request: &'r Request, _data: Data) -> Outcome<'r> {
/// # fn handler<'r>(request: &'r Request, _data: Data) -> HandlerFuture<'r> {
/// # Outcome::from(request, "Hello, world!")
/// # }
///