Skip to content

Commit e0c1090

Browse files
weihangloseanmonstar
authored andcommitted
docs(client): send_request doc test to async/await
1 parent 7c2622a commit e0c1090

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/client/conn.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,30 +191,25 @@ where
191191
/// # Example
192192
///
193193
/// ```
194-
/// # extern crate futures;
195-
/// # extern crate hyper;
196-
/// # extern crate http;
194+
/// # #![feature(async_await)]
197195
/// # use http::header::HOST;
198196
/// # use hyper::client::conn::SendRequest;
199197
/// # use hyper::Body;
200-
/// use futures::Future;
201198
/// use hyper::Request;
202199
///
203-
/// # fn doc(mut tx: SendRequest<Body>) {
200+
/// # async fn doc(mut tx: SendRequest<Body>) -> hyper::Result<()> {
204201
/// // build a Request
205202
/// let req = Request::builder()
206203
/// .uri("/foo/bar")
207204
/// .header(HOST, "hyper.rs")
208205
/// .body(Body::empty())
209206
/// .unwrap();
210207
///
211-
/// // send it and get a future back
212-
/// let fut = tx.send_request(req)
213-
/// .map(|res| {
214-
/// // got the Response
215-
/// assert!(res.status().is_success());
216-
/// });
217-
/// # drop(fut);
208+
/// // send it and await a Response
209+
/// let res = tx.send_request(req).await?;
210+
/// // assert the Response
211+
/// assert!(res.status().is_success());
212+
/// # Ok(())
218213
/// # }
219214
/// # fn main() {}
220215
/// ```

0 commit comments

Comments
 (0)