Skip to content

Commit f0478c6

Browse files
committed
feat(rt): export hyper::rt::main attribute macro
Usage: #[hyper::rt::main] async fn main() { // async stuff in here }
1 parent 8d4ae27 commit f0478c6

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

examples/hello.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(async_await)]
22
#![deny(warnings)]
3-
extern crate hyper;
4-
extern crate pretty_env_logger;
53

64
use hyper::{Body, Request, Response, Server};
75
use hyper::service::{make_service_fn, service_fn};
@@ -10,8 +8,8 @@ async fn hello(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
108
Ok(Response::new(Body::from("Hello World!")))
119
}
1210

13-
#[tokio::main]
14-
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
11+
#[hyper::rt::main]
12+
pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1513
pretty_env_logger::init();
1614

1715
let addr = ([127, 0, 0, 1], 3000).into();

src/rt.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub use futures_core::Stream;
1111

1212
use tokio;
1313

14+
pub use tokio::main;
15+
1416
use self::inner::Spawn;
1517

1618
/// Spawns a future on the default executor.
@@ -34,18 +36,6 @@ where
3436
}
3537
}
3638

37-
/// Start the Tokio runtime using the supplied future to bootstrap execution.
38-
///
39-
/// # Example
40-
///
41-
/// See the [server documentation](::server) for an example of its usage.
42-
pub fn run<F>(f: F)
43-
where
44-
F: Future<Output = ()> + Send + 'static
45-
{
46-
tokio::run(f);
47-
}
48-
4939
// Make the `Spawn` type an unnameable, so we can add
5040
// methods or trait impls to it later without a breaking change.
5141
mod inner {

0 commit comments

Comments
 (0)