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:
committed by
Sean McArthur
parent
1d00bb29d4
commit
0d3cbe28fc
@@ -11,7 +11,7 @@ use hyper::Client;
|
|||||||
// A simple type alias so as to DRY.
|
// A simple type alias so as to DRY.
|
||||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use futures_util::TryStreamExt;
|
|||||||
// A simple type alias so as to DRY.
|
// A simple type alias so as to DRY.
|
||||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap();
|
let url = "http://jsonplaceholder.typicode.com/users".parse().unwrap();
|
||||||
let users = fetch_json(url).await?;
|
let users = fetch_json(url).await?;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ async fn hello(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
|
|||||||
Ok(Response::new(Body::from("Hello World!")))
|
Ok(Response::new(Body::from("Hello World!")))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ async fn index2(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
|
|||||||
Ok(Response::new(Body::from(INDEX2)))
|
Ok(Response::new(Body::from(INDEX2)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -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>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use hyper::{Client, Error, Server};
|
|||||||
use hyper::service::{make_service_fn, service_fn};
|
use hyper::service::{make_service_fn, service_fn};
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ static INDEX: &str = "examples/send_file_index.html";
|
|||||||
static INTERNAL_SERVER_ERROR: &[u8] = b"Internal Server Error";
|
static INTERNAL_SERVER_ERROR: &[u8] = b"Internal Server Error";
|
||||||
static NOTFOUND: &[u8] = b"Not Found";
|
static NOTFOUND: &[u8] = b"Not Found";
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use tokio::runtime::current_thread;
|
|||||||
|
|
||||||
// Configure a runtime that runs everything on the current thread,
|
// Configure a runtime that runs everything on the current thread,
|
||||||
// which means it can spawn !Send futures...
|
// which means it can spawn !Send futures...
|
||||||
#[hyper::rt::main(single_thread)]
|
#[tokio::main(single_thread)]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::sync::{Arc, atomic::{AtomicUsize, Ordering}};
|
|||||||
use hyper::{Body, Error, Response, Server};
|
use hyper::{Body, Error, Response, Server};
|
||||||
use hyper::service::{make_service_fn, service_fn};
|
use hyper::service::{make_service_fn, service_fn};
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ async fn client_upgrade_request(addr: SocketAddr) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// For this example, we just make a server and our own client to talk to
|
// 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
|
// it, so the exact port isn't important. Instead, let the OS give us an
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ async fn response_examples(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[hyper::rt::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,6 @@
|
|||||||
pub use std::future::Future;
|
pub use std::future::Future;
|
||||||
pub use futures_core::Stream;
|
pub use futures_core::Stream;
|
||||||
|
|
||||||
use tokio;
|
|
||||||
|
|
||||||
pub use tokio::main;
|
|
||||||
|
|
||||||
use self::inner::Spawn;
|
use self::inner::Spawn;
|
||||||
|
|
||||||
/// Spawns a future on the default executor.
|
/// Spawns a future on the default executor.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
//! use hyper::service::{make_service_fn, service_fn};
|
//! use hyper::service::{make_service_fn, service_fn};
|
||||||
//!
|
//!
|
||||||
//! # #[cfg(feature = "runtime")]
|
//! # #[cfg(feature = "runtime")]
|
||||||
//! # #[hyper::rt::main]
|
//! # #[tokio::main]
|
||||||
//! async fn main() {
|
//! async fn main() {
|
||||||
//! // Construct our SocketAddr to listen on...
|
//! // Construct our SocketAddr to listen on...
|
||||||
//! let addr = ([127, 0, 0, 1], 3000).into();
|
//! let addr = ([127, 0, 0, 1], 3000).into();
|
||||||
@@ -379,7 +379,7 @@ impl<I, E> Builder<I, E> {
|
|||||||
/// # #[cfg(not(feature = "runtime"))]
|
/// # #[cfg(not(feature = "runtime"))]
|
||||||
/// # fn main() {}
|
/// # fn main() {}
|
||||||
/// # #[cfg(feature = "runtime")]
|
/// # #[cfg(feature = "runtime")]
|
||||||
/// # #[hyper::rt::main]
|
/// # #[tokio::main]
|
||||||
/// # async fn main() {
|
/// # async fn main() {
|
||||||
/// use hyper::{Body, Error, Response, Server};
|
/// use hyper::{Body, Error, Response, Server};
|
||||||
/// use hyper::service::{make_service_fn, service_fn};
|
/// use hyper::service::{make_service_fn, service_fn};
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ where
|
|||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #![feature(async_await)]
|
/// # #![feature(async_await)]
|
||||||
/// # #[cfg(feature = "runtime")]
|
/// # #[cfg(feature = "runtime")]
|
||||||
/// # #[hyper::rt::main]
|
/// # #[tokio::main]
|
||||||
/// # async fn main() {
|
/// # async fn main() {
|
||||||
/// use std::net::TcpStream;
|
/// use std::net::TcpStream;
|
||||||
/// use hyper::{Body, Error, Request, Response, Server};
|
/// use hyper::{Body, Error, Request, Response, Server};
|
||||||
|
|||||||
Reference in New Issue
Block a user