mirror of
				https://github.com/async-rs/async-std.git
				synced 2025-10-31 00:36:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
	
		
			512 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
	
		
			512 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Lists files in a directory given as an argument.
 | |
| 
 | |
| use std::env::args;
 | |
| 
 | |
| use async_std::fs;
 | |
| use async_std::io;
 | |
| use async_std::prelude::*;
 | |
| use async_std::task;
 | |
| 
 | |
| fn main() -> io::Result<()> {
 | |
|     let path = args().nth(1).expect("missing path argument");
 | |
| 
 | |
|     task::block_on(async {
 | |
|         let mut dir = fs::read_dir(&path).await?;
 | |
| 
 | |
|         while let Some(res) = dir.next().await {
 | |
|             let entry = res?;
 | |
|             println!("{}", entry.file_name().to_string_lossy());
 | |
|         }
 | |
| 
 | |
|         Ok(())
 | |
|     })
 | |
| }
 |