From 0d3cbe28fc599a0ddfd083efe14e4305a920a42b Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Tue, 23 Jul 2019 02:06:36 +0900 Subject: [PATCH] refactor(rt): remove re-export of `tokio::main` (#1879) Closes #1878. BREAKING CHANGE: Replace all usage of `rt::main` with `tokio::main`. --- examples/client.rs | 2 +- examples/client_json.rs | 2 +- examples/hello.rs | 2 +- examples/multi_server.rs | 2 +- examples/params.rs | 2 +- examples/proxy.rs | 2 +- examples/send_file.rs | 2 +- examples/single_threaded.rs | 2 +- examples/state.rs | 2 +- examples/upgrades.rs | 2 +- examples/web_api.rs | 2 +- src/rt.rs | 4 ---- src/server/mod.rs | 4 ++-- src/service/make_service.rs | 2 +- 14 files changed, 14 insertions(+), 18 deletions(-) diff --git a/examples/client.rs b/examples/client.rs index acd86388..3a4d83d7 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -11,7 +11,7 @@ use hyper::Client; // A simple type alias so as to DRY. type Result = std::result::Result>; -#[hyper::rt::main] +#[tokio::main] async fn main() -> Result<()> { pretty_env_logger::init(); diff --git a/examples/client_json.rs b/examples/client_json.rs index 861e6db1..94d35cd9 100644 --- a/examples/client_json.rs +++ b/examples/client_json.rs @@ -12,7 +12,7 @@ use futures_util::TryStreamExt; // A simple type alias so as to DRY. type Result = std::result::Result>; -#[hyper::rt::main] +#[tokio::main] async fn main() -> Result<()> { let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap(); let users = fetch_json(url).await?; diff --git a/examples/hello.rs b/examples/hello.rs index 2de0c5ea..92110796 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -8,7 +8,7 @@ async fn hello(_: Request) -> Result, hyper::Error> { Ok(Response::new(Body::from("Hello World!"))) } -#[hyper::rt::main] +#[tokio::main] pub async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/examples/multi_server.rs b/examples/multi_server.rs index 058d5e67..173df59b 100644 --- a/examples/multi_server.rs +++ b/examples/multi_server.rs @@ -18,7 +18,7 @@ async fn index2(_: Request) -> Result, hyper::Error> { Ok(Response::new(Body::from(INDEX2))) } -#[hyper::rt::main] +#[tokio::main] async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/examples/params.rs b/examples/params.rs index 2589949a..d4d20ea8 100644 --- a/examples/params.rs +++ b/examples/params.rs @@ -80,7 +80,7 @@ async fn param_example(req: Request) -> Result, hyper::Erro } } -#[hyper::rt::main] +#[tokio::main] async fn main() -> Result<(), Box> { pretty_env_logger::init(); diff --git a/examples/proxy.rs b/examples/proxy.rs index 36f5e823..b1615d17 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -5,7 +5,7 @@ use hyper::{Client, Error, Server}; use hyper::service::{make_service_fn, service_fn}; use std::net::SocketAddr; -#[hyper::rt::main] +#[tokio::main] async fn main() { pretty_env_logger::init(); diff --git a/examples/send_file.rs b/examples/send_file.rs index 1e59d891..c9ca15cd 100644 --- a/examples/send_file.rs +++ b/examples/send_file.rs @@ -11,7 +11,7 @@ static INDEX: &str = "examples/send_file_index.html"; static INTERNAL_SERVER_ERROR: &[u8] = b"Internal Server Error"; static NOTFOUND: &[u8] = b"Not Found"; -#[hyper::rt::main] +#[tokio::main] async fn main() { pretty_env_logger::init(); diff --git a/examples/single_threaded.rs b/examples/single_threaded.rs index 1105f060..5d582857 100644 --- a/examples/single_threaded.rs +++ b/examples/single_threaded.rs @@ -10,7 +10,7 @@ use tokio::runtime::current_thread; // Configure a runtime that runs everything on the current thread, // which means it can spawn !Send futures... -#[hyper::rt::main(single_thread)] +#[tokio::main(single_thread)] async fn main() { pretty_env_logger::init(); diff --git a/examples/state.rs b/examples/state.rs index 4438959e..a1fd9ce0 100644 --- a/examples/state.rs +++ b/examples/state.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, atomic::{AtomicUsize, Ordering}}; use hyper::{Body, Error, Response, Server}; use hyper::service::{make_service_fn, service_fn}; -#[hyper::rt::main] +#[tokio::main] async fn main() { pretty_env_logger::init(); diff --git a/examples/upgrades.rs b/examples/upgrades.rs index b79a8a5d..8df189b5 100644 --- a/examples/upgrades.rs +++ b/examples/upgrades.rs @@ -109,7 +109,7 @@ async fn client_upgrade_request(addr: SocketAddr) -> Result<()> { Ok(()) } -#[hyper::rt::main] +#[tokio::main] async fn main() { // For this example, we just make a server and our own client to talk to // it, so the exact port isn't important. Instead, let the OS give us an diff --git a/examples/web_api.rs b/examples/web_api.rs index 71ce0b32..ffd42b28 100644 --- a/examples/web_api.rs +++ b/examples/web_api.rs @@ -98,7 +98,7 @@ async fn response_examples( } } -#[hyper::rt::main] +#[tokio::main] async fn main() -> Result<()> { pretty_env_logger::init(); diff --git a/src/rt.rs b/src/rt.rs index 2d473b12..240c701f 100644 --- a/src/rt.rs +++ b/src/rt.rs @@ -9,10 +9,6 @@ pub use std::future::Future; pub use futures_core::Stream; -use tokio; - -pub use tokio::main; - use self::inner::Spawn; /// Spawns a future on the default executor. diff --git a/src/server/mod.rs b/src/server/mod.rs index 4fb18034..449b48d5 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -24,7 +24,7 @@ //! use hyper::service::{make_service_fn, service_fn}; //! //! # #[cfg(feature = "runtime")] -//! # #[hyper::rt::main] +//! # #[tokio::main] //! async fn main() { //! // Construct our SocketAddr to listen on... //! let addr = ([127, 0, 0, 1], 3000).into(); @@ -379,7 +379,7 @@ impl Builder { /// # #[cfg(not(feature = "runtime"))] /// # fn main() {} /// # #[cfg(feature = "runtime")] - /// # #[hyper::rt::main] + /// # #[tokio::main] /// # async fn main() { /// use hyper::{Body, Error, Response, Server}; /// use hyper::service::{make_service_fn, service_fn}; diff --git a/src/service/make_service.rs b/src/service/make_service.rs index 80142874..09524833 100644 --- a/src/service/make_service.rs +++ b/src/service/make_service.rs @@ -120,7 +120,7 @@ where /// ```rust,no_run /// # #![feature(async_await)] /// # #[cfg(feature = "runtime")] -/// # #[hyper::rt::main] +/// # #[tokio::main] /// # async fn main() { /// use std::net::TcpStream; /// use hyper::{Body, Error, Request, Response, Server};