Documentation in examples recommends using `tokio 0.2` as dependency, while README.md recomends `tokio 0.1`. I've updated comments according to readme.
		
			
				
	
	
		
			26 lines
		
	
	
		
			798 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			798 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| #![deny(warnings)]
 | |
| 
 | |
| // This is using the `tokio` runtime. You'll need the following dependency:
 | |
| //
 | |
| // `tokio = { version = "1", features = ["full"] }`
 | |
| #[cfg(not(target_arch = "wasm32"))]
 | |
| #[tokio::main]
 | |
| async fn main() -> Result<(), reqwest::Error> {
 | |
|     let res = reqwest::get("https://hyper.rs").await?;
 | |
| 
 | |
|     println!("Status: {}", res.status());
 | |
| 
 | |
|     let body = res.text().await?;
 | |
| 
 | |
|     println!("Body:\n\n{}", body);
 | |
| 
 | |
|     Ok(())
 | |
| }
 | |
| 
 | |
| // The [cfg(not(target_arch = "wasm32"))] above prevent building the tokio::main function
 | |
| // for wasm32 target, because tokio isn't compatible with wasm32.
 | |
| // If you aren't building for wasm32, you don't need that line.
 | |
| // The two lines below avoid the "'main' function not found" error when building for wasm32 target.
 | |
| #[cfg(target_arch = "wasm32")]
 | |
| fn main() {}
 |