From f0478c62677a953aae84aa8d976bec1d28ef21b1 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 10 Jul 2019 14:12:21 -0700 Subject: [PATCH] feat(rt): export `hyper::rt::main` attribute macro Usage: #[hyper::rt::main] async fn main() { // async stuff in here } --- examples/hello.rs | 6 ++---- src/rt.rs | 14 ++------------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/examples/hello.rs b/examples/hello.rs index d9617971..2de0c5ea 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,7 +1,5 @@ #![feature(async_await)] #![deny(warnings)] -extern crate hyper; -extern crate pretty_env_logger; use hyper::{Body, Request, Response, Server}; use hyper::service::{make_service_fn, service_fn}; @@ -10,8 +8,8 @@ async fn hello(_: Request) -> Result, hyper::Error> { Ok(Response::new(Body::from("Hello World!"))) } -#[tokio::main] -pub async fn main() -> Result<(), Box> { +#[hyper::rt::main] +pub async fn main() -> Result<(), Box> { pretty_env_logger::init(); let addr = ([127, 0, 0, 1], 3000).into(); diff --git a/src/rt.rs b/src/rt.rs index 2220f483..2d473b12 100644 --- a/src/rt.rs +++ b/src/rt.rs @@ -11,6 +11,8 @@ pub use futures_core::Stream; use tokio; +pub use tokio::main; + use self::inner::Spawn; /// Spawns a future on the default executor. @@ -34,18 +36,6 @@ where } } -/// Start the Tokio runtime using the supplied future to bootstrap execution. -/// -/// # Example -/// -/// See the [server documentation](::server) for an example of its usage. -pub fn run(f: F) -where - F: Future + Send + 'static -{ - tokio::run(f); -} - // Make the `Spawn` type an unnameable, so we can add // methods or trait impls to it later without a breaking change. mod inner {