Skip to content

Commit 47407f5

Browse files
weihangloseanmonstar
authored andcommitted
docs(server): serve_connection doc test to async/await
1 parent ca10ca6 commit 47407f5

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/server/conn.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,31 +331,25 @@ impl<E> Http<E> {
331331
/// # Example
332332
///
333333
/// ```
334-
/// # extern crate hyper;
335-
/// # extern crate tokio_io;
336-
/// # #[cfg(feature = "runtime")]
337-
/// # extern crate tokio;
334+
/// # #![feature(async_await)]
338335
/// # use hyper::{Body, Request, Response};
339336
/// # use hyper::service::Service;
340337
/// # use hyper::server::conn::Http;
338+
/// # #[cfg(feature = "runtime")]
341339
/// # use tokio_io::{AsyncRead, AsyncWrite};
342340
/// # #[cfg(feature = "runtime")]
343-
/// # fn run<I, S>(some_io: I, some_service: S)
341+
/// # async fn run<I, S>(some_io: I, some_service: S)
344342
/// # where
345-
/// # I: AsyncRead + AsyncWrite + Send + 'static,
343+
/// # I: AsyncRead + AsyncWrite + Unpin + Send + 'static,
346344
/// # S: Service<ReqBody=Body, ResBody=Body> + Send + 'static,
347345
/// # S::Future: Send
348346
/// # {
349-
/// # use hyper::rt::Future;
350-
/// # use tokio::reactor::Handle;
351347
/// let http = Http::new();
352348
/// let conn = http.serve_connection(some_io, some_service);
353349
///
354-
/// let fut = conn.map_err(|e| {
350+
/// if let Err(e) = conn.await {
355351
/// eprintln!("server connection error: {}", e);
356-
/// });
357-
///
358-
/// hyper::rt::spawn(fut);
352+
/// }
359353
/// # }
360354
/// # fn main() {}
361355
/// ```

0 commit comments

Comments
 (0)