mirror of https://github.com/smol-rs/smol
24 lines
503 B
Rust
24 lines
503 B
Rust
// TODO: document
|
|
//! Lists files in a directory given as an argument.
|
|
|
|
use std::env;
|
|
use std::fs;
|
|
|
|
use futures::io;
|
|
use futures::prelude::*;
|
|
use smol::blocking;
|
|
|
|
fn main() -> io::Result<()> {
|
|
let path = env::args().nth(1).expect("missing path argument");
|
|
|
|
smol::run(async move {
|
|
let mut dir = smol::iter(blocking!(fs::read_dir(path))?);
|
|
|
|
while let Some(res) = dir.next().await {
|
|
println!("{}", res?.file_name().to_string_lossy());
|
|
}
|
|
|
|
Ok(())
|
|
})
|
|
}
|