docs(client): send_request doc test to async/await
This commit is contained in:
committed by
Sean McArthur
parent
7c2622abef
commit
e0c1090ca7
@@ -191,16 +191,13 @@ where
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # extern crate futures;
|
/// # #![feature(async_await)]
|
||||||
/// # extern crate hyper;
|
|
||||||
/// # extern crate http;
|
|
||||||
/// # use http::header::HOST;
|
/// # use http::header::HOST;
|
||||||
/// # use hyper::client::conn::SendRequest;
|
/// # use hyper::client::conn::SendRequest;
|
||||||
/// # use hyper::Body;
|
/// # use hyper::Body;
|
||||||
/// use futures::Future;
|
|
||||||
/// use hyper::Request;
|
/// use hyper::Request;
|
||||||
///
|
///
|
||||||
/// # fn doc(mut tx: SendRequest<Body>) {
|
/// # async fn doc(mut tx: SendRequest<Body>) -> hyper::Result<()> {
|
||||||
/// // build a Request
|
/// // build a Request
|
||||||
/// let req = Request::builder()
|
/// let req = Request::builder()
|
||||||
/// .uri("/foo/bar")
|
/// .uri("/foo/bar")
|
||||||
@@ -208,13 +205,11 @@ where
|
|||||||
/// .body(Body::empty())
|
/// .body(Body::empty())
|
||||||
/// .unwrap();
|
/// .unwrap();
|
||||||
///
|
///
|
||||||
/// // send it and get a future back
|
/// // send it and await a Response
|
||||||
/// let fut = tx.send_request(req)
|
/// let res = tx.send_request(req).await?;
|
||||||
/// .map(|res| {
|
/// // assert the Response
|
||||||
/// // got the Response
|
/// assert!(res.status().is_success());
|
||||||
/// assert!(res.status().is_success());
|
/// # Ok(())
|
||||||
/// });
|
|
||||||
/// # drop(fut);
|
|
||||||
/// # }
|
/// # }
|
||||||
/// # fn main() {}
|
/// # fn main() {}
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
Reference in New Issue
Block a user