refactor(rt): remove re-export of tokio::main (#1879)

Closes #1878.

BREAKING CHANGE: Replace all usage of `rt::main` with `tokio::main`.
This commit is contained in:
Daiki Mizukami
2019-07-23 02:06:36 +09:00
committed by Sean McArthur
parent 1d00bb29d4
commit 0d3cbe28fc
14 changed files with 14 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ use hyper::Client;
// A simple type alias so as to DRY.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[hyper::rt::main]
#[tokio::main]
async fn main() -> Result<()> {
pretty_env_logger::init();

View File

@@ -12,7 +12,7 @@ use futures_util::TryStreamExt;
// A simple type alias so as to DRY.
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
#[hyper::rt::main]
#[tokio::main]
async fn main() -> Result<()> {
let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap();
let users = fetch_json(url).await?;

View File

@@ -8,7 +8,7 @@ async fn hello(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
Ok(Response::new(Body::from("Hello World!")))
}
#[hyper::rt::main]
#[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
pretty_env_logger::init();

View File

@@ -18,7 +18,7 @@ async fn index2(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
Ok(Response::new(Body::from(INDEX2)))
}
#[hyper::rt::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
pretty_env_logger::init();

View File

@@ -80,7 +80,7 @@ async fn param_example(req: Request<Body>) -> Result<Response<Body>, hyper::Erro
}
}
#[hyper::rt::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
pretty_env_logger::init();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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

View File

@@ -98,7 +98,7 @@ async fn response_examples(
}
}
#[hyper::rt::main]
#[tokio::main]
async fn main() -> Result<()> {
pretty_env_logger::init();