feat(rt): export hyper::rt::main attribute macro
				
					
				
			Usage:
    #[hyper::rt::main]
    async fn main() {
        // async stuff in here
    }
			
			
This commit is contained in:
		| @@ -1,7 +1,5 @@ | |||||||
| #![feature(async_await)] | #![feature(async_await)] | ||||||
| #![deny(warnings)] | #![deny(warnings)] | ||||||
| extern crate hyper; |  | ||||||
| extern crate pretty_env_logger; |  | ||||||
|  |  | ||||||
| use hyper::{Body, Request, Response, Server}; | use hyper::{Body, Request, Response, Server}; | ||||||
| use hyper::service::{make_service_fn, service_fn}; | use hyper::service::{make_service_fn, service_fn}; | ||||||
| @@ -10,8 +8,8 @@ async fn hello(_: Request<Body>) -> Result<Response<Body>, hyper::Error> { | |||||||
|     Ok(Response::new(Body::from("Hello World!"))) |     Ok(Response::new(Body::from("Hello World!"))) | ||||||
| } | } | ||||||
|  |  | ||||||
| #[tokio::main] | #[hyper::rt::main] | ||||||
| pub async fn main() -> Result<(), Box<dyn std::error::Error>> { | pub async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { | ||||||
|     pretty_env_logger::init(); |     pretty_env_logger::init(); | ||||||
|  |  | ||||||
|     let addr = ([127, 0, 0, 1], 3000).into(); |     let addr = ([127, 0, 0, 1], 3000).into(); | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								src/rt.rs
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/rt.rs
									
									
									
									
									
								
							| @@ -11,6 +11,8 @@ pub use futures_core::Stream; | |||||||
|  |  | ||||||
| use tokio; | 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. | ||||||
| @@ -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: F) |  | ||||||
| where |  | ||||||
|     F: Future<Output = ()> + Send + 'static |  | ||||||
| { |  | ||||||
|     tokio::run(f); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Make the `Spawn` type an unnameable, so we can add | // Make the `Spawn` type an unnameable, so we can add | ||||||
| // methods or trait impls to it later without a breaking change. | // methods or trait impls to it later without a breaking change. | ||||||
| mod inner { | mod inner { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user